开发者

Adding resources file in an assembly using visual studio 2010

开发者 https://www.devze.com 2023-02-05 05:52 出处:网络
I wanted to have culture specific resources in my application. What i did is i created a Resource.txt and compile this to Resource.resources using resgen.exe.

I wanted to have culture specific resources in my application. What i did is i created a Resource.txt and compile this to Resource.resources using resgen.exe.

However, if i access my resource using:

System.Resources.ResourceManager rm = new System.Resources.ResourceManager("ResourceManager.Resources",
                             Assembly.GetExecutingAssembly());

and if i will call Console.WriteLine(rm.GetString("test")); it will throw an error

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "ResourceManager.Resources.resources" was correctly embedded or linked into assembly "ResourceManager" at compile time, or that all the satellite assemblies required are loadable and fully signed.

My resource file is Resources.txt with text inside "test=testing" and will be compiled into Resources.resources.

Question:

  1. How can i link the compiled resources to the assembly using the IDE(Visual Studio 2010)?, not using the csc, or AL on command line.

  2. Is there any other recommended way how to accomplish this? I have added .resx files in visual st开发者_运维技巧udio and its working, however its not favorable for me, i favored the txt file with key=value type set up.


Try to use


System.Resources.ResourceManager rm = new System.Resources.ResourceManager("Resources",
                             Assembly.GetExecutingAssembly());

instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消