我正在使用.NET Core 2.1加载调用Assembly.ReflectionOnlyLoadFrom(...)
的程序集,但遇到System.PlatformNotSupportedException
异常。 Microsoft documentation似乎表明它应该工作。实施了吗?如果没有,是否有其他方法可以使用.NET Core从.NET 4.7.2程序集获取导出的类型?
Assembly.ReflectionOnlyLoadFrom(fileName) 'Assembly.ReflectionOnlyLoadFrom(fileName)' threw an exception of type 'System.PlatformNotSupportedException' Data: {System.Collections.ListDictionaryInternal} HResult: -2146233031 HelpLink: null InnerException: null Message: "ReflectionOnly loading is not supported on this platform." Source: "System.Private.CoreLib" StackTrace: " at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)" TargetSite: {System.Reflection.Assembly ReflectionOnlyLoadFrom(System.String)}
答案 0 :(得分:0)
如上所述,.net内核尚不支持反射。 您可以从LAB的存储库中使用实验性的 TypeLoader 。
如果要使用实验性NuGet,则需要遵循以下说明: https://github.com/dotnet/corefxlab(基本上添加了NuGet存储库-https://dotnet.myget.org/F/dotnet-corefxlab/)并获取System.Reflection.TypeLoader。
虽然期望不高:)