MissingManifestResourceException on Windows Phone 8.1 with .resx resources

后端 未结 4 2120
野性不改
野性不改 2021-02-07 11:59

I\'m developing a Windows Phone 8.1 app that also targets Android(Xamarin)

As ever I added my string resources(.resx) on a PCL and referenced them on my launcher project

相关标签:
4条回答
  • 2021-02-07 12:25

    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

    0 讨论(0)
  • 2021-02-07 12:25

    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.

    0 讨论(0)
  • 2021-02-07 12:27

    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")]
    
    0 讨论(0)
  • 2021-02-07 12:36

    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!

    0 讨论(0)
提交回复
热议问题