Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. some problem with ResourceManager

some problem with ResourceManager

Scheduled Pinned Locked Moved C#
helpquestioncsharpvisual-studiocom
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Areff
    wrote on last edited by
    #1

    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 ---------------------

    P T 2 Replies Last reply
    0
    • A Areff

      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 ---------------------

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      What was the error message?

      Deja View - the feeling that you've seen this post before.

      1 Reply Last reply
      0
      • A Areff

        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 ---------------------

        T Offline
        T Offline
        Talal Sultan
        wrote on last edited by
        #3

        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 called myPage.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 replace myFile.aspx. Now to access the resouces: Assuming you have a label lblFirstname 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(); where GlobalFile 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

        A 1 Reply Last reply
        0
        • T Talal Sultan

          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 called myPage.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 replace myFile.aspx. Now to access the resouces: Assuming you have a label lblFirstname 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(); where GlobalFile 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

          A Offline
          A Offline
          Areff
          wrote on last edited by
          #4

          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 ---------------------

          T 1 Reply Last reply
          0
          • A Areff

            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 ---------------------

            T Offline
            T Offline
            Talal Sultan
            wrote on last edited by
            #5

            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); where pageClassName is the name of the page class where your code is located and namespaceName 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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups