0

I would like to use resource files to internationalize my .net application. I'm trying a little test on a field of my Login page :

 <td class="libelleCnx" id="texteMdp" runat="server">

 Mot de passe :</td>

I created the resource file with visual studio, it's in App_LocalData, it's named Login.resx and contains the follwing resource :

 <data name="texteMotDePasse" xml:space="preserve">

 <value>Ze password</value>

 </data>

In my Login class, I try to use that resource like this:

 protected ResourceManager manager = new ResourceManager("Login", typeof(Login).Assembly);

 protected void Page_Load(object sender, System.EventArgs e)

 {
 ...
 texteMdp.InnerText = manager.GetString("Login.texteMotDePasse");
 ...
 }

But I get a System.Resources.MissingManifestResourceException when trying to access my Login page...

I can modify the field with "texteMdp.InnerText = "stuff" " so I guess the problem is not with the field. I think that the Resource File is not detected... Anyone has an idea why ?

Thank you !

user1948708
  • 43
  • 1
  • 2
  • 10
  • Check this question, may help: http://stackoverflow.com/questions/1327692/c-what-does-missingmanifestresourceexception-mean-and-how-to-fix-it – tnw Jun 04 '14 at 16:58
  • ResourceManager reads *compiled* .resx files, the ones that are converted to binary .resources files by resgen.exe and get embedded in the assembly manifest. Surely you missed a step somewhere :) – Hans Passant Jun 04 '14 at 17:54
  • Thank you, I'll try that ! Is resgen a fonction of Visual Studio ? Didn't see something else to do with the files, I'll look more carefully – user1948708 Jun 04 '14 at 18:36
  • So, I compiled the my file with resgen.exe, but now my web page is not found (I don't get the exception). It "works" again if I delete the compiled file. I guess that I have to embed it in an assembly to make it work, but I tried the al commande ("al file /out:Login.dll") but I get an AL 1047 error: error importing the file '...' -- 0x8013110e. How do I put my ressource in a satellite ? – user1948708 Jun 05 '14 at 10:27
  • In the end, Hans Passant solution worked, you just have to compile it with resgen.exe. My later problem is only because apparently there can't be a ressource.resource and a resource.resx file in the place, or else you get an error. (after my last comment, I tried deleting the resx file instead of the resource and it worked just fine – user1948708 Jun 08 '14 at 20:42

1 Answers1

0

you can use directly resourseName.StringName for example:

Login.texteMotDePasse
  • I read that somewhere to, but it didn't work :s. Maybe it's a matter of version of Visual Studio ? I work on 2005. Or does what Hans Passant commented above applies to that technique to ? – user1948708 Jun 04 '14 at 18:39