The runtime config for the Microsoft.XmlSerializer.Generator specifies to run on netcoreapp2.0. When reflecting over application assembly to generator serializer, if the assembly is referencing for example NetCoreApp3.0, the version of System.Runtime referenced by the library can't be loaded.
The fix is to change the assembly loading code to use System.Reflection.MetadataLoadContext to reflect over the application assembly. We do use Type.GetCustomAttributes at least in sgen.cs so we would also need to make changes to use Type.GetCustomAttributesData. XmlSerializer.GenerateSerializer does the bulk of the work so there might need to be changes there as well.
Original issue: dotnet/corefx#41286
The runtime config for the Microsoft.XmlSerializer.Generator specifies to run on netcoreapp2.0. When reflecting over application assembly to generator serializer, if the assembly is referencing for example NetCoreApp3.0, the version of System.Runtime referenced by the library can't be loaded.
The fix is to change the assembly loading code to use System.Reflection.MetadataLoadContext to reflect over the application assembly. We do use
Type.GetCustomAttributesat least in sgen.cs so we would also need to make changes to useType.GetCustomAttributesData. XmlSerializer.GenerateSerializer does the bulk of the work so there might need to be changes there as well.Original issue: dotnet/corefx#41286