我正在使用 .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)}
最佳答案
如上所述,.net core 尚不支持反射。 您可以使用 LAB 存储库中的实验性用途 TypeLoader。
如果您想使用实验性 NuGet,您需要遵循以下说明: https://github.com/dotnet/corefxlab (主要是添加 NuGet 存储库 - https://dotnet.myget.org/F/dotnet-corefxlab/)并获取 System.Reflection.TypeLoader。
虽然不要指望得到太多支持:)
关于c# - 调用 Assembly.ReflectionOnlyLoadFrom 时出现 System.PlatformNotSupportedException 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54426870/