Description
Generated XmlSerializers DLL (from Microsoft.XmlSerializer.Generator) cause FileNotFoundException when used in COM host.
Reproduction Steps
- Extract attached example COMServerDemo.zip
- Run dotnet publish on solution. Command: dotnet publish COMClient.sln
- Open priviledged command line
- cd into publish directory. Command: cd COMServer/bin/Debug/net6.0/publish
- Register COM Host DLL. Command: regsvr32.exe COMServer.comhost.dll
- Run COMClient in Visual Studio as Debug (Set breakpoint on line var xs = new XmlSerializer(typeof(Class1)); in Server.cs)
- Optional - unregister DLL. Command: regsvr32.exe /u COMServer.comhost.dll
Expected behavior
ComClient program should execute without problems.
Actual behavior
Program prints exception:
System.IO.FileNotFoundException: Could not load file or assembly 'XmlLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Das System kann die angegebene Datei nicht finden.
File name: 'XmlLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract.CanSerialize(Type type)
at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type type, String defaultNamespace, XmlSerializerImplementation& contract)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
at COMServer.Server.IServer.ComputePi() in C:\dev\COMServerDemo\COMServer\Server.cs:line 25
Regression?
No response
Known Workarounds
Deleting or renaming XmlLib.XmlSerializers.dll before the execution of the program. (XmlSerializer will then build DLL at runtime in memory I suppose)
Configuration
Which version of .NET is the code running on?
.NET 6.0
What OS and version, and what distro if applicable?
Windows 10 20H2 x64
What is the architecture (x64, x86, ARM, ARM64)?
x64
Do you know whether it is specific to that configuration?
Yes, works when using it without COM host
If you're using Blazor, which web browser(s) do you see this issue in?
No
Other information
No response
Description
Generated XmlSerializers DLL (from Microsoft.XmlSerializer.Generator) cause FileNotFoundException when used in COM host.
Reproduction Steps
Expected behavior
ComClient program should execute without problems.
Actual behavior
Program prints exception:
System.IO.FileNotFoundException: Could not load file or assembly 'XmlLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Das System kann die angegebene Datei nicht finden.
File name: 'XmlLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract.CanSerialize(Type type)
at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type type, String defaultNamespace, XmlSerializerImplementation& contract)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
at COMServer.Server.IServer.ComputePi() in C:\dev\COMServerDemo\COMServer\Server.cs:line 25
Regression?
No response
Known Workarounds
Deleting or renaming XmlLib.XmlSerializers.dll before the execution of the program. (XmlSerializer will then build DLL at runtime in memory I suppose)
Configuration
Which version of .NET is the code running on?
.NET 6.0
What OS and version, and what distro if applicable?
Windows 10 20H2 x64
What is the architecture (x64, x86, ARM, ARM64)?
x64
Do you know whether it is specific to that configuration?
Yes, works when using it without COM host
If you're using Blazor, which web browser(s) do you see this issue in?
No
Other information
No response