calling resources
-
Hi, I'm trying to call resources via the ResourceManager class. The idea is to be able to translate the application text when the application loads. I have tried the following:
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); ResourceManager resourcemanager = new ResourceManager("Resources", Assembly.GetExecutingAssembly());
and call a string:string info = resourcemanager.GetString("info_help");
("info_help" is the name of the item in my Resources.en-US.resx file.) I get a MissingManifestResourceException error when theGetString
method executes. What could be the problem here? tnx! [EDIT]MSDN is being a real b*tch to me on this subject... :( [/EDIT] Coulda, woulda, shoulda doesn't matter if you don't. -- modified at 5:46 Tuesday 25th April, 2006 -
Hi, I'm trying to call resources via the ResourceManager class. The idea is to be able to translate the application text when the application loads. I have tried the following:
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); ResourceManager resourcemanager = new ResourceManager("Resources", Assembly.GetExecutingAssembly());
and call a string:string info = resourcemanager.GetString("info_help");
("info_help" is the name of the item in my Resources.en-US.resx file.) I get a MissingManifestResourceException error when theGetString
method executes. What could be the problem here? tnx! [EDIT]MSDN is being a real b*tch to me on this subject... :( [/EDIT] Coulda, woulda, shoulda doesn't matter if you don't. -- modified at 5:46 Tuesday 25th April, 2006Not sure if this will apply to your case, but I had a similar issue. I was simply trying to access an embedded resource of strings, no culture-specific stuff. I resolved it by qualifying the resource name with the assembly's default namespace: assembly name: MyAssembly default NameSpace: MyAssembly embedded resource: MyResources.resources
ResourceManager rm = new ResourceManager("MyAssembly.MyResources", this.GetType().Assembly); string resourceValue = rm.GetString("resourceKey");
I had similar experiences with MSDN... Hope this helps. --Tym! -
Not sure if this will apply to your case, but I had a similar issue. I was simply trying to access an embedded resource of strings, no culture-specific stuff. I resolved it by qualifying the resource name with the assembly's default namespace: assembly name: MyAssembly default NameSpace: MyAssembly embedded resource: MyResources.resources
ResourceManager rm = new ResourceManager("MyAssembly.MyResources", this.GetType().Assembly); string resourceValue = rm.GetString("resourceKey");
I had similar experiences with MSDN... Hope this helps. --Tym!tnx, I already solved the problem. It seems you have to add a resource to the project, I used (for the first one) the one that is there by default. Don't know where the difference is, but it works now. btw: i've tried this: ResourceManager rm = new ResourceManager("MyAssembly.MyResources", this.GetType().Assembly); string resourceValue = rm.GetString("resourceKey"); as first thing :-). Coulda, woulda, shoulda doesn't matter if you don't. :jig: :jig: :jig: :jig: :jig: :jig: :jig: :jig: :jig: :jig: :jig: