some problem with ResourceManager
-
hi , i am using VS.Net 2005 AND I Want to use ResourceManager to read from my resource file . i was add 1 resource file with vs.net and .net create resource file in Properties folder (Properties/resource.Resx) . i am trying to create resource manager with following code
ResourceManager rm = new ResourceManager("resource",Assembly.GetExecutingAssembly());
Error ocurred in RunTime in instasiate statment . what is the proble ? tnx 4 ur help............--------------------- Areff Bahrami(KAVEH) Areff.HB@Gmail.com ---------------------
-
hi , i am using VS.Net 2005 AND I Want to use ResourceManager to read from my resource file . i was add 1 resource file with vs.net and .net create resource file in Properties folder (Properties/resource.Resx) . i am trying to create resource manager with following code
ResourceManager rm = new ResourceManager("resource",Assembly.GetExecutingAssembly());
Error ocurred in RunTime in instasiate statment . what is the proble ? tnx 4 ur help............--------------------- Areff Bahrami(KAVEH) Areff.HB@Gmail.com ---------------------
What was the error message?
Deja View - the feeling that you've seen this post before.
-
hi , i am using VS.Net 2005 AND I Want to use ResourceManager to read from my resource file . i was add 1 resource file with vs.net and .net create resource file in Properties folder (Properties/resource.Resx) . i am trying to create resource manager with following code
ResourceManager rm = new ResourceManager("resource",Assembly.GetExecutingAssembly());
Error ocurred in RunTime in instasiate statment . what is the proble ? tnx 4 ur help............--------------------- Areff Bahrami(KAVEH) Areff.HB@Gmail.com ---------------------
With .NET 2.0, there is an easier way to do things. First of all, you need to create the local resources folder called
App_LocalResources
or the global resources folder,App_GlobalResources
. Files located in the local resources folder will have to be named like their corresponding ASPX files; files in the global resources folder can be named whatever you like. Now, suppose you have a file calledmyPage.aspx
. If you decide to use the local resouces, it means that you will create resource files only for that page. Your resource files should be named:myPage.aspx.resx
(this one should always be present), then for different languages you would have: for US English:myPage.aspx.en-US.resx
, for Switzerland French:myPage.aspx.fr-CH.resx
, etc.... For the global resources, you can use any file name you like to replacemyFile.aspx
. Now to access the resouces: Assuming you have a labellblFirstname
to which you would like to assign the value of the resource called "firstname
" in the resource files, you would write: For local resource:lblFirstname.Text = GetLocalResourceObject("firstname").ToString();
For global resource:lblFirstname.Text = GetGlobalResourceObject("GlobalFile", "firstname").ToString();
whereGlobalFile
will be the name of the global resource file. I hope this helps :) Talal-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
-
With .NET 2.0, there is an easier way to do things. First of all, you need to create the local resources folder called
App_LocalResources
or the global resources folder,App_GlobalResources
. Files located in the local resources folder will have to be named like their corresponding ASPX files; files in the global resources folder can be named whatever you like. Now, suppose you have a file calledmyPage.aspx
. If you decide to use the local resouces, it means that you will create resource files only for that page. Your resource files should be named:myPage.aspx.resx
(this one should always be present), then for different languages you would have: for US English:myPage.aspx.en-US.resx
, for Switzerland French:myPage.aspx.fr-CH.resx
, etc.... For the global resources, you can use any file name you like to replacemyFile.aspx
. Now to access the resouces: Assuming you have a labellblFirstname
to which you would like to assign the value of the resource called "firstname
" in the resource files, you would write: For local resource:lblFirstname.Text = GetLocalResourceObject("firstname").ToString();
For global resource:lblFirstname.Text = GetGlobalResourceObject("GlobalFile", "firstname").ToString();
whereGlobalFile
will be the name of the global resource file. I hope this helps :) Talal-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
tanks for your help but i want to know why error ocured in this code and how can i fix this problem ?
ResourceManager rm = new ResourceManager("resource", Assembly.GetExecutingAssembly()):
there was this resource file : Properties/resource.resx tnx--------------------- Areff Bahrami(KAVEH) Areff.HB@Gmail.com ---------------------
-
tanks for your help but i want to know why error ocured in this code and how can i fix this problem ?
ResourceManager rm = new ResourceManager("resource", Assembly.GetExecutingAssembly()):
there was this resource file : Properties/resource.resx tnx--------------------- Areff Bahrami(KAVEH) Areff.HB@Gmail.com ---------------------
I think I remember that when I was working on a project in .NET 1.1 I got some problems with the
GetExecutingAssembly()
. I don't remember exactly why it wasn't working but I used another piece of code to solve the problem. Also, I think you should put the whole name of the resource file (with namespace reference). If you have a file called resource.resx in a folder "Properties
" of project "myProject
", you should put the file as "myProject.Properties.resource
". The code I use is this:ResourceManager rm = new ResourceManager("myProject.Properties.resource", Type.GetType("namespaceName.pageClassName").Assembly);
wherepageClassName
is the name of the page class where your code is located andnamespaceName
is the namespace where this class is located. Talal-- If this is a post that has been helpful to you, please vote for it. Thank you! "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook