Ask a questionAsk a question
 

Answerresources in satellite assembly causes exception

  • Thursday, July 02, 2009 8:45 PMBill Swartz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    <!--DIV {margin:0px;}-->
    I have a simple wpf application.

    The project file contains "<UICulture>en-US</UICulture>".

    AssemblyInfo.cs contains
    [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]

    Resources.resx uses the Custom Tool
    PublicResXFileCodeGenerator

    There is a single string resource named ButtonText.

    I signed the assembly.

    The following line generates an error.
                string str = Properties.Resources.ButtonText;

    The message is:
                Message="Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure \"WpfLocTest.Properties.Resources.en-US.resources\" was correctly embedded or linked into assembly \"WpfLocTest\" at compile time, or that all the satellite assemblies required are loadable and fully signed."

    Does anyone see a solution?

    Bill

Answers

All Replies

  • Thursday, July 02, 2009 9:40 PMDavid M MortonMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    It seems like you're trying to mix the idea of Satellite resources and resources that are compiled into the assembly.  My guess is that you were following the walkthrough here:

    http://msdn.microsoft.com/en-us/library/cc668131.aspx

    And you finished it, but it still doesn't work right.  Based on what you're telling me, it seems like you left a couple of steps out.

    Things to make sure of:

    1.  The Resources.resx shouldn't be using the custom tool.
    2.  Resources.resx should be named Resources.en-US.resx.
    3.  The call to get the resource should be more like:

    ResourceManager rm = new ResourceManager(
        "WpfLocTest.Properties.Resources",
        Assembly.GetExecutingAssembly());
    MessageBox.Show(rm.GetString("ButtonText"));


    David Morton - http://blog.davemorton.net/ - @davidmmorton - ForumsBrowser, a WPF MSDN Forums Client
  • Friday, July 03, 2009 3:50 AMTarun Jindal Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You can try two more things:

    1: right click on your resources.resx file. Goto properties and provide the CustomToolNamespace as WPFLocTest.Properties

    2: Also make sure that you have made all the resources as public. By default they are internal.


    Hope it helps.
    Cheers,
    Tarun
    Developer
  • Friday, July 03, 2009 3:33 PMBill Swartz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I hadn't found that walkthrough. It showed me what I needed to know. Thanks.
    Bill
    • Marked As Answer byBill Swartz Friday, July 03, 2009 3:33 PM
    •  
  • Friday, July 03, 2009 3:55 PMDavid M MortonMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Bill,

    If it was one of our posts that led you to the answer, it would be nice if you could mark our posts as the answer, and not your own.  The answer posts show up at the top of the list now, so marking the proper post as answer will greatly help anyone else who sees this thread to quickly find the answer.
    David Morton - http://blog.davemorton.net/ - @davidmmorton - ForumsBrowser, a WPF MSDN Forums Client