Microsoft 开发人员网络 >
论坛主页
>
Windows Presentation Foundation (WPF)
>
resources in satellite assembly causes exception
resources in satellite assembly causes exception
- <!--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
答案
- I hadn't found that walkthrough. It showed me what I needed to know. Thanks.
Bill- 已标记为答案Bill Swartz 2009年7月3日 15:33
全部回复
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- 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 - I hadn't found that walkthrough. It showed me what I needed to know. Thanks.
Bill- 已标记为答案Bill Swartz 2009年7月3日 15:33
- 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

