VS 2008 does not understand .resource files
I'm trying to add globalization support to my C# application. According to MSDN, there should be one embedded resource file for neutral culture and satellite DLLs with resource files for other cultures.
I've created 2 satellite DLLs without any problems and got my app to automatically load right one using ResourceManager. But I can't embed default neutral culture resource file into my executable. When I remove all satellite DLLs or set culture to some culture I don't have satellite DLL for, I get exception "Could not find any resources appropriate for the specified culture or the neutral culture." when application attempts to create ResourceManager.
It looks like VS 2008 does not include my .resource file into main assembly. I've tried different ways to get resource file embedded: compiling it by resgen.exe from text file and adding it to the project; changing its name t开发者_Python百科o add second .resources extension; creating .resx file with same name; etc. And I still don't see the way to get resource file embedded and used by ResourceManager - I'm having same exception.
What is the right way to add default neutral culture resource file to application in VS 2008 ?
Ok, I've solved this problem by little 'hack'.
I've compiled resource file using resgen.exe, as described in MSDN, then added it to the project, renamed it to "resources" and changed build action from "None" to "Embedded resource".
Looks like VS 2008 adds "." as prefix to resource file name. So if u will name your resource file ".resources" it won't work cuz actually VS will name it "..resources".
in .Net the resource files are using the .resx extension. To have it 'embedded' in your project, make sure the "Custom Tool" in the properties page of the .resx file is using the "ResXCodeGenerator"
Hope this helps,
精彩评论