我正在开发一个在Debug模式下工作完美的UWP,当我以发布模式编译它时,它没有错误地编译,但是当我运行这个应用程序时,我有一个在.Net标准2.0库中使用函数的进程,这个库会抛出一个 System.Security。没有为此程序集找到元数据。
这是我的rd.xml
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<!--
An Assembly element with Name="*Application*" applies to all assemblies in
the application package. The asterisks are not wildcards.
-->
<Assembly Name="*Application*" Dynamic="Required All" />
<!-- Add your application specific runtime directives here. -->
<Assembly Name="System.Runtime" Dynamic="Required All" />
<Assembly Name="System.Security" Dynamic="Required All" />
<Type Name="Windows.Foundation.TypedEventHandler{Microsoft.UI.Xaml.Controls.NavigationView,Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs}" MarshalObject="Public" />
<Type Name="Microsoft.UI.Xaml.Controls.NavigationView">
<Event Name="ItemInvoked" Dynamic="Required"/>
</Type>
<Type Name="System.Configuration.AppSettingsSection" Serialize="Required Public" />
</Application>
</Directives>抛出错误的那条线是这条。
Assembly System_Security_Assembly = Assembly.Load("System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");尽管这个很好用。
Assembly cripXmlAssembly = Assembly.Load("System.Security.Cryptography.Xml");我读过关于向RD.xml文件添加指令的文章,但我认为这适用于UWP,在这种情况下,异常是由抛出的。有人能帮我解释一下这件事吗?
这是一个复制品。
发布于 2019-11-26 09:12:12
通过讨论,我们发现在CoreRT中不支持程序集的动态加载(这是使用.NET原生工具链在发布版中编译应用程序时使用的运行时):
我们知道.NET本机在构建发布模式时用于应用程序。
来自这个文档的:
.NET原生结合UTC编译器使用CoreRT为UWP应用程序提供本机编译。
线程 ::
不受支持的特性:动态加载 (例如Assembly.LoadFile)、动态代码生成 (例如System.Reflection.Emit)、特定于Windows的互操作 (例如COM、WinRT)
这里还提到,目前在CoreRT中这是不可能的。
实际上,唯一可以“加载”的程序集是静态链接到正在运行的本机进程的程序集。
https://stackoverflow.com/questions/58326197
复制相似问题