Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 App

The PCL assembly contains an embedded string resource table (via an RESX file in the project) and a simple class that allows callers to get strings out of the string resource table. The PCL is designed to allow sharing of strings between the .NET and UWP assemblies.

When the .NET Unit Test Library is run, the unit tests call the .NET assembly, which gets strings out of the PCL assembly. This works as expected.

When the UWP Unit Test App is run, the unit tests call the UWP assembly, which gets strings out of 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 call to GetForViewIndependentUse() failed with a COMException stating that "ResourceMap Not Found".

What's going on? This call chain works for the .NET unit test stack. I have checked to ensure that the Neutral Language is set to "English" for all assemblies. What is the best way for me to share a string table between the .NET assembly and the UWP assembly?

like image 990
JeffFerguson Avatar asked May 16 '16 16:05

JeffFerguson


1 Answers

I was dealing with same "MissingManifestResourceException" for the past few days. I also checked the Microsoft Blog Post and this MVP Post regarding Xamarin. After applying the proposed solutions I got the same error as you "ResourceMap Not Found".

Finally, I decided to go back to the main issue and I carefully checked the description for the error "MissingManifestResourceException" in MSDN, and it says:

The exception that is thrown if the main assembly does not contain the resources for the neutral culture, and an appropriate 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 set a Neutral Culture (Language)

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

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

Problem Solved!

like image 94
danieljaguiar Avatar answered Nov 14 '22 21:11

danieljaguiar