MissingManifestResourceException from PCL assembly code called from UWP

My Visual Studio 2015 solution has the following projects:

  • .NET assembly
  • UWP assembly
  • PCL assembly
  • .NET Unit Test Library
  • UWP Unit Test Application

The PCL assembly contains an embedded row resource table (via the .resx file in the project) and a simple class that allows callers to output rows from the row table. PCL is designed to share strings between .NET assemblies and UWP.

When the .NET Unit Test library is running, unit tests invoke the .NET assembly, which extracts the rows from the PCL assembly. This works as expected.

When the UWP Unit Test application is running, unit tests invoke the UWP assembly, which outputs the lines from the PCL assembly. This fails with the following exception message:

System.Resources.MissingManifestResourceException: Unable to load resources for resource file [blah] in package [guid].

I tried this solution , but the GetForViewIndependentUse() call failed with a COMException , indicating that "ResourceMap was not found."

What's happening? This call chain works for the .NET Unit Test stack. I checked that the Neutral language is set to "English" for all assemblies. What is the best way to exchange a row table between a .NET assembly and a UWP assembly?

+5
source share
1 answer

Over the past few days, I have dealt with the same "MissingManifestResourceException". I also checked the Microsoft Blog Post and this MVP Post regarding Xamarin. After applying the proposed solutions, I got the same error as "ResourceMap Not Found".

Finally, I decided to return to the main problem, and I carefully checked the "MissingManifestResourceException" error description on MSDN and said:

An exception that occurs if the main assembly does not contain resources for a neutral culture and the corresponding satellite assembly is missing.

Source: https://msdn.microsoft.com/en-us/library/system.resources.missingmanifestresourceexception(v=vs.110).aspx

So, I just went to PCL and installed Neutral Culture (Language)

  • In Solution Explorer, right-click your project, and then click Properties.
  • In the left navigation bar, select "Application" and then click "Assembly Information".
  • In the Assembly Information dialog box, select a language from the Neutral Language drop-down list.
  • Click OK.

Source: https://msdn.microsoft.com/en-us/library/bb385967.aspx

The problem is solved!

+6
source

All Articles