Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi!
I am trying to make my user control (dll project) multi language with resources, but i have a dim problem!
I can get my aproaching string just first! i mean when resourcemanager.getstring returns a string, then after that it doesnt return anything! it loads assembly correctly always! problem is after running line of GetString method!
should i release resource after any string returned? (i used it with ReleaseAllResources() method)
stacktrace show internal methods of .Net!

System.NullReferenceException was caught
HResult=-2147467261
Message=Object reference not set to an instance of an object.

here is my code!
C#
Type t = Type.GetType("A CLASS IN NAMESPACE");
System.Reflection.Assembly asm = t.Assembly;
System.Resources.ResourceManager rm = new System.Resources.ResourceManager("Namespace.ResourceName", asm);
string s=rm.GetString(FieldName);
// rm.ReleaseAllResources();
return s;


I named my resource files like this
HTML
fa-IR.resx
en-US.resx
es-MX.resx

these are embedded resources!
thank you!

EDIT:
It is a user control project!
Posted
Updated 12-May-14 2:29am
v2
Comments
[no name] 10-May-14 16:35pm    
http://msdn.microsoft.com/en-us/library/d17ax2xk(v=vs.110).aspx
ali_heidari_ 10-May-14 17:01pm    
I read it before, but didnt get my answer!
[no name] 10-May-14 17:09pm    
Then go read it again!
Nelek 10-May-14 17:33pm    
My virtual 5
ali_heidari_ 10-May-14 17:34pm    
Did you read it? do you know my answer? are you sure reading it, is not wasting time ?
anyway i do!

1 solution

You are trying to achieve some .NET globalization/localization features which are already developed and provided for you with .NET FCL. The idea is correct, but .NET implementation automates the localization much deeper that you are only trying to do. It is based on satellite assemblies (basically, resource-only assemblies which are named properly for using them automatically, depending on the current culture your application switches on), and the fallback mechanism, where the satellite assemblies are chosen automatically trying to match the required culture with the cultures of available satellite assemblies.

Please see my past answers:
How to use a Single resx file for 3 languages[^],
globalization/localization problem in winform .net[^],
globalization in winforms[^].

—SA
 
Share this answer
 
Comments
johannesnestler 12-May-14 9:05am    
who downvoted? I think this is a "perfect" answer...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900