Reading config file other than web.config

Discussion in 'ASP .Net' started by M Irfan, Apr 17, 2007.

  1. M Irfan

    M Irfan Guest

    Recently I have started working in .NET 2.0. I am developing a web
    service application that references a DLL component written in C# 2.0.
    The component has its own config file which contains settings related
    to business logic coded in that component. I can reference and load
    the component but unable to read load the custom config file of that
    component. I know that the same thing is possible if my host
    application is any Exe application and using
    "ExeConfigurationFileMap", "OpenMappedExeConfiguration" I can read
    configuration file other than app.config but the same is not possible
    if I use "WebConfigurationFileMap" and "OpenMappedWebConfiguration".
    Using both these we can only define the mappings b/w virtual and
    physical directories but can't read config file other than
    web.config.

    string dummyVirtualPath = "/test_web_2005";
    string physicalPath = @"C:\Inetpub\wwwroot
    \test_web_2005\Bin";
    string configFileName =
    System.IO.Path.GetFileName(assembly.CodeBase) + ".config";
    WebConfigurationFileMap map = new WebConfigurationFileMap();
    map.VirtualDirectories.Add(dummyVirtualPath, new
    VirtualDirectoryMapping(physicalPath, true));
    Configuration config =
    WebConfigurationManager.OpenMappedWebConfiguration(map,
    dummyVirtualPath);

    Is there any other idea to implement the same. Thanks in advance.

    Regards
    Irfan
     
    M Irfan, Apr 17, 2007
    #1
    1. Advertising

  2. See my response in the C# newsgroup. Actually, this is the best group for the
    question, I just saw that one first.
    Peter

    --
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short urls & more: http://ittyurl.net




    "M Irfan" wrote:

    > Recently I have started working in .NET 2.0. I am developing a web
    > service application that references a DLL component written in C# 2.0.
    > The component has its own config file which contains settings related
    > to business logic coded in that component. I can reference and load
    > the component but unable to read load the custom config file of that
    > component. I know that the same thing is possible if my host
    > application is any Exe application and using
    > "ExeConfigurationFileMap", "OpenMappedExeConfiguration" I can read
    > configuration file other than app.config but the same is not possible
    > if I use "WebConfigurationFileMap" and "OpenMappedWebConfiguration".
    > Using both these we can only define the mappings b/w virtual and
    > physical directories but can't read config file other than
    > web.config.
    >
    > string dummyVirtualPath = "/test_web_2005";
    > string physicalPath = @"C:\Inetpub\wwwroot
    > \test_web_2005\Bin";
    > string configFileName =
    > System.IO.Path.GetFileName(assembly.CodeBase) + ".config";
    > WebConfigurationFileMap map = new WebConfigurationFileMap();
    > map.VirtualDirectories.Add(dummyVirtualPath, new
    > VirtualDirectoryMapping(physicalPath, true));
    > Configuration config =
    > WebConfigurationManager.OpenMappedWebConfiguration(map,
    > dummyVirtualPath);
    >
    > Is there any other idea to implement the same. Thanks in advance.
    >
    > Regards
    > Irfan
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Apr 17, 2007
    #2
    1. Advertising

  3. M Irfan

    M Irfan Guest

    On Apr 17, 6:02 pm, Peter Bromberg [C# MVP]
    <> wrote:
    > See my response in the C# newsgroup. Actually, this is the best group for the
    > question, I just saw that one first.
    > Peter
    >
    > --
    > Site: http://www.eggheadcafe.com
    > UnBlog: http://petesbloggerama.blogspot.com
    > Short urls & more: http://ittyurl.net
    >
    >
    >
    >
    >
    > "M Irfan" wrote:
    > > Recently I have started working in .NET 2.0. I am developing a web
    > > service application that references a DLL component written in C# 2.0.
    > > The component has its ownconfigfilewhich contains settings related
    > > to business logic coded in that component. I can reference and load
    > > the component but unable to read load the customconfigfileof that
    > > component. I know that the same thing is possible if my host
    > > application is any Exe application and using
    > > "ExeConfigurationFileMap", "OpenMappedExeConfiguration" I can read
    > > configurationfileotherthanapp.configbut the same is not possible
    > > if I use "WebConfigurationFileMap" and "OpenMappedWebConfiguration".
    > > Using both these we can only define the mappings b/w virtual and
    > > physical directories but can't readconfigfileotherthan
    > >web.config.

    >
    > > string dummyVirtualPath = "/test_web_2005";
    > > string physicalPath = @"C:\Inetpub\wwwroot
    > > \test_web_2005\Bin";
    > > string configFileName =
    > > System.IO.Path.GetFileName(assembly.CodeBase) + ".config";
    > > WebConfigurationFileMap map = new WebConfigurationFileMap();
    > > map.VirtualDirectories.Add(dummyVirtualPath, new
    > > VirtualDirectoryMapping(physicalPath, true));
    > > Configurationconfig=
    > > WebConfigurationManager.OpenMappedWebConfiguration(map,
    > > dummyVirtualPath);

    >
    > > Is there anyotheridea to implement the same. Thanks in advance.

    >
    > > Regards
    > > Irfan


    Hi Peter,

    Thanks for the response. I know that I can use web.config but I dont
    want to use that. The component will be reponsible for sending data to
    multiple partners and at run time partner specific object would be
    instantiated using Reflection. For the time being I think its should
    use a custom config reader. Design wise I believe it would be good if
    objects and their configurations are laoded dynamically without being
    depended on web.config.

    Regards
    Irfan.
     
    M Irfan, Apr 18, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    506
  2. Replies:
    0
    Views:
    802
  3. Chang Lui

    authorization - other than web.config?

    Chang Lui, May 10, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    426
    Alexey Smirnov
    May 10, 2007
  4. Diego
    Replies:
    2
    Views:
    162
    Stefan Rusterholz
    Aug 16, 2008
  5. kampy
    Replies:
    9
    Views:
    360
    Steven D'Aprano
    Oct 19, 2012
Loading...

Share This Page