locked
Can we add new resource file dynamically at run-time RRS feed

  • Question

  • User632277935 posted

    In our web application we need to keep various company's settings. For eg "Shippingpickup","ZipCodeCaption","DefaultCountry","AllowToEditInvoice", etc


    These settings are different for various companies and are placed in web.config as key-value pair.

    Initially, we have tried do simplify this process by adding a company_settings table in the DB so as to allow us to add companies on the fly. However, this method makes it very difficult to add a new setting  since it would require us to add a column to the company_settings table and thus would require code changes as well as stored procedure changes.
    Now we have added separate global resource files for each company's settings. But, whenever we want to add new company to our website, we need to add a new resource file for that company. Adding a resource file requires compilation, and thus the application needs to be restarted. I was wondering if there is a way that we can add a new resource file dynamically at run-time.

    Or are resource files not the right thing to use here? Is there a better method of tackling this issue?

    Thursday, February 18, 2010 8:03 AM

Answers

  • User-653327211 posted

    You can add a resource file dynamically at runtime. Here is some code:

    dim rm as new ResourceManager("MyApplication.res",Assembly.GetExecutingAssembly()) 
    
    dim ZipCodeCaption as string = rm.GetString("ZipCodeCaption")
    


    The other method I would think would be better for this scenario is the Profile Manager. This allows you to assign different values based upon the user.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 18, 2010 9:40 AM

All replies

  • User-653327211 posted

    You can add a resource file dynamically at runtime. Here is some code:

    dim rm as new ResourceManager("MyApplication.res",Assembly.GetExecutingAssembly()) 
    
    dim ZipCodeCaption as string = rm.GetString("ZipCodeCaption")
    


    The other method I would think would be better for this scenario is the Profile Manager. This allows you to assign different values based upon the user.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 18, 2010 9:40 AM
  • User632277935 posted

    Thanks jgangwisch for your early reply.

    Resource manager's way is good to solve this problem.

    I am talking about ADDING new resource files dynamically & not loading existing resources.

    So, can we still go ahead with this approach ?

    Friday, February 19, 2010 12:02 AM
  • User632277935 posted

    I found out that resource file only loads resource keys.It doesnt creates new resources dynamically at runtime.

    Friday, February 19, 2010 3:47 AM