【发布时间】:2020-02-08 02:13:33
【问题描述】:
我正在开发一个在调试模式下完美运行的 UWP,当我在发布模式下编译它时,它编译时没有错误,但是当我运行应用程序时,我有一个使用 中的函数的进程。抛出 System.IO.FileNotFoundException System.Security 的 Net Standard 2.0 库。找不到此程序集的元数据。
这是我的 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,在这种情况下,网络标准 dll 会引发异常。有人可以解释一下吗?
这是一个复制品。
【问题讨论】:
-
是的,这正是您需要测试 .NETNative 构建并编辑 rd.xml 的原因。当您不显示任何内容时,您将无法获得具体的建议。
-
感谢您的回答我更新了问题。
-
我创建了一个空白的 UWP 项目和一个类库(.Net Standard 2.0),当我在类库中添加
Assembly.Load("System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");行并调用它时,它运行良好。那么你使用的是什么架构?如果你创建一个空白的应用程序来使用它,会不会出现同样的错误?并且可以提供一个简单的可以复制的样本吗? -
我附上了一个重现问题link的样本。你试过realese模式吗?我使用 x64 作为目标。
标签: uwp filenotfoundexception .net-standard .net-native