MSDN > 論壇首頁 > Windows Presentation Foundation (WPF) > resources in satellite assembly causes exception
發問發問
 

已答覆resources in satellite assembly causes exception

  • Thursday, 2 July, 2009 20:45Bill Swartz 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    <!--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

解答

所有回覆

  • Thursday, 2 July, 2009 21:40David M MortonMVP使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    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, 3 July, 2009 3:50Tarun Jindal 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    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, 3 July, 2009 15:33Bill Swartz 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆
    I hadn't found that walkthrough. It showed me what I needed to know. Thanks.
    Bill
  • Friday, 3 July, 2009 15:55David M MortonMVP使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    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