none
Access to RESW resources

    Question

  • Hi,

    In .NET, when we create a Resources file (.RESX) and add strings, a designer file is created and the strings are available as a convenient property on the Resources object (for example Resources.MyErrorMessage). In WinRT C# applications, I add a RESW file but no designer file gets created.

    Is it expected that we access the resources through an instance of the ResourceManager class? If yes, it is a little annoying due to the necessary usage of precompiler switches (#if WIN8) which makes code less portable.

    Is it a temporary issue, did I miss something?

    thanks,

    Laurent


    Software engineering - http://www.galasoft.ch
    Sunday, September 25, 2011 1:17 PM

Answers

  • @Laurent - you didn't miss anything.  In the developer preview you would use an instance of ResourceLoader to pull strings out (GetString()).  During the world-readiness talks we heard the feedback from the .NET developers about strongly-typed access to the resources.  For now, using the ResourceLoader is the mechanism to retrieve the string resources you have.
    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
    Sunday, September 25, 2011 5:00 PM

All replies

  • @Laurent - you didn't miss anything.  In the developer preview you would use an instance of ResourceLoader to pull strings out (GetString()).  During the world-readiness talks we heard the feedback from the .NET developers about strongly-typed access to the resources.  For now, using the ResourceLoader is the mechanism to retrieve the string resources you have.
    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
    Sunday, September 25, 2011 5:00 PM
  • This works:

    private string GetString(string id)
    {
        ResourceLoader loader = new ResourceLoader("StringResources");
       
    return loader.GetString(id);
    }

    (Note that you do not prefix the resource with the default namespace like you do in resx).

    Sunday, August 19, 2012 2:04 AM