Freigeben über


Windows 10 UAP app throws System.Resources.MissingManifestResourceException error when accessing strings from a RESX

If you try to access a string from a RESX file embedded in your Windows 10 UWP application or library in Visual Studio 2015, you'll end up getting this exception:

System.Resources.MissingManifestResourceException was unhandled by user code
  HResult=-2146233038
  Message=Unable to load resources for resource file "Contoso.UI.GeneralStrings" in package "d1c46561-bf90-4e62-9e4f-e2c1f3fe0fd1".
  Source=mscorlib
  StackTrace:
       at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
       at Contoso.UI.GeneralStrings.get_ApplicationName()
       at Contoso.UI.MainPage..ctor()
       at Contoso.UI.Contoso_UI_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage()
       at Contoso.UI.Contoso_UI_XamlTypeInfo.XamlUserType.ActivateInstance()

 

Turns out that you cannot take an existing RESX file and embed it inside your UWP 10 assembly. It comes down to the way the assembly gets compiled and this is no different than how it behaved in the Windows 8.1 days. If you have a need to use a RESX with your Windows 10 application, the workaround is to place your RESX files inside a Portable Class Library (PCL) and then have your UWP assemblies reference that PCL. This will get you around this limitation and allow you to still continue to use RESX instead of having to be forced to move to RESW.