runtime: Soap encoded serialization fails on a netstandard library when running on Desktop.
When using soap encoded serialization on a netstandard library and running on Desktop it fails as Desktop has a difference in behavior where it looks for System types (e.g System.Enum, System.Object) in mscorlib.dll but since it was built against netstandard the types it is loading are from netstandard.dll so costumers would hit an InvalidOperationException like this one:
System.InvalidOperationException : Unable to generate a temporary class (result=1).
error CS0012: The type 'System.Enum' is defined in an assembly that is not referenced.
You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
There needs to be a solution here for 2.0 as costumers could be hitting this when using soap encoded serialization on a netstandard library and trying to run it on Desktop.
For more information see: https://github.com/dotnet/corefx/pull/18743#issuecomment-296306832
cc: @weshaggard @shmao
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 23 (13 by maintainers)
Hi Guys, I’m also hitting this issue in my project and it is blocking further development. I’ve created a .NET Standard library and reference this from a .NET Framework 4.7.1 console application. Inside the library I use XmlSerialization but it does not work due to the thread error:
System.InvalidOperationException: 'Unable to generate a temporary class (result=1). error CS0012: The type ‘System.Object’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’. error CS0012: The type ‘System.Enum’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’.
I’m considering to re-target .NET Standard library back to .NET Framework until the issue is solved. I’d like to know if this is the best workaround for now or do I have alternatives?