locked
Writing into .resx file using 'ResXResourceWriter' at runtime, clears the Session, Cache, Application states RRS feed

  • Question

  • User-1832868798 posted

    See the below code:

    //-------------------------------------------------

    1    ResXResourceWriter rw = new ResXResourceWriter("MyResource.aspx.en-GB.resx");
    2    rw.AddResource("StringData", "My String");
    3    rw.AddResource("IntegerData", 2);
    4    ........
    5    rw.Close();

    //-------------------------------------------------

    In my ASP,NET  Web Portal, I am using the above code to do the 'Translation' functionality. Actually the need is allow a Administrator to define the translation of the Web-Pages for the various languages at runtime.

    This all is happening at the run time.
    But the probelm is once the system saves the file after writing, it clears the Session, Cache and Application state. Clearing these State objects definietly leads to halt in the Web-Application and ultimately throws the flow of control to Login page.

    i.e. It is behaving the way we encounter, after wriiting into Web.config / Global.asax at runtime.

    Please help asap. 

     

     

     
    Tuesday, March 27, 2007 10:19 AM

Answers

  • User-503940700 posted

    Any changes made to resource files or files under /bin folder will lead to an application restart clearing your session/application variables. This restart is actually neccessary because the ASP.NET runtime needs to load the new/modified values fromthe changed files and clear its old cache (for e.g. it caches the resource files values to avoid multiple reads to the files).

    As far as I know you cannot avoid this if you are changing the files at runtime. What you can do is to use Database instead of resource files for this runtime "translation".

    Hope this helps,

    Vivek

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 28, 2007 12:58 AM

All replies

  • User-503940700 posted

    Any changes made to resource files or files under /bin folder will lead to an application restart clearing your session/application variables. This restart is actually neccessary because the ASP.NET runtime needs to load the new/modified values fromthe changed files and clear its old cache (for e.g. it caches the resource files values to avoid multiple reads to the files).

    As far as I know you cannot avoid this if you are changing the files at runtime. What you can do is to use Database instead of resource files for this runtime "translation".

    Hope this helps,

    Vivek

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 28, 2007 12:58 AM
  • User-1832868798 posted

    Thanks Vivek. I understand the root cause, but still looking for some Trick.

     

    Wednesday, March 28, 2007 3:15 AM
  • User1024908470 posted

    Did you find a trick to that? I am having the same issue. 

    Wednesday, March 17, 2010 5:03 PM
  • User1541999426 posted

    Make sure Resources.resx is not read-only

    Tuesday, November 20, 2012 4:44 AM