MissingManifestResourceException on Windows Phone 8.1 with .resx resources

给你一囗甜甜゛ 提交于 2019-12-03 05:21:30

Our team ran into a similar issue which was tracked down to the runtime and not the PCL, WinRT component, or application package. That is, the resources exist within the PCL assembly, within the application package resources.pri file, but just cannot be found at runtime.

There is an active Microsoft Connect report here:

https://connect.microsoft.com/VisualStudio/feedback/details/991028/issue-using-resx-files-on-winrt-apps-windows-phone-and-windows

Our workaround was for the WinRT component to inject into each generated Resources class of each referenced PCL our own derived ResourceManager which redirected the call to the WinRT ResourceLoader instead. I've written a blog post that describes that workaround:

http://blogs.msdn.com/b/philliphoff/archive/2014/11/19/missingmanifestresourceexception-when-using-portable-class-libraries-in-winrt.aspx

I got to the bottom of this today. While bundling the app package, resources in dependencies that are not for a language being used by the app are stripped out. To prevent this from happening, add the following assembly-level attribute to your application.

using System.Resources;

[assembly: NeutralResourcesLanguage("en")]

I had the same behaviour. Today I created a new PCL Library (with another name) and copied the resx file to this project. I modified all references and everything just works fine in my WinRt (Windows Store) App now!

There was the string 'resources' in the portable class library name. Perhaps this was the problem!

I am able to reproduce this issue launching DVD sample and unfortunately in my project. I have an WP Silverlight 8.1 project registering a Windows Runtime Component Background Task and both of them using a Portable Class Library sharing some common localized strings as resources (.resx), among other things. The exception is thrown from Background Task when calling any property to get strings on generated .Design.cs class (only Release + Device).

In order to fix this I tried, without success, to use directly ResourceManager and/or to add .resx files directly into the Background Task.

I ended-up porting needed strings to .resw files and use the new "WinRT preferred" way via Windows.ApplicationModel.Resources.ResourceLoader in the Background Task project.

Seems to me that ResourceManager is not compatible with Windows Runtime anymore in release.

This is not necessary an answer, but is better than nothing since I do not have 50 reputation points for a comment.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!