c# - 调用 Assembly.ReflectionOnlyLoadFrom 时出现 System

我正在使用 .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/

相关文章:

gitlab - 如何从私有(private) gitlab repo 创建公开发布?

python - 使用聚类从文档列表中找出所有潜在的相似文档

ruby-on-rails - rake 数据库 :setup is giving Library

wpf - ListView 组标题显示多次

java - soap 请求 java 中缺少 header

spring-boot - 如何在 Spring Security oauth2 中调试重定向 ur

javascript - 为什么 Chrome 在使用 Typed.js 时难以呈现表情符号?

typo3 - 使用流体创建数组和对象 f :variable

c# - 未续订 Azure 服务总线消息锁?

angular - 如何在 ngrx 效果中使用 LatestFrom 进行单元测试