I’m developing an UWP that works perfect in Debug mode, when I compiled it in Release Mode it compiles without an error, but when I run the app, I have a process the uses a function in a .Net Standard 2.0 library that throws a System.IO.FileNotFoundException System.Security. No metadata found for this assembly.
This is my 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>
And the line that throws the error is this one.
Assembly System_Security_Assembly = Assembly.Load("System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
Even though this one works fine.
Assembly cripXmlAssembly = Assembly.Load("System.Security.Cryptography.Xml");
I’ve read about adding a directive to an RD.xml files but I think this applies to UWP, and in this case the Exception is being thrown by the Net Standard dll. Could someone please shed some light on this?
Here is a repro.
Assembly.Load("System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
in Class Library and call it, it works well. So what architecture are you using? If you create a blank app to use it, will the same error occur? And can you provide a simple sample that can be reproduced? – Faywang - MSFT