configSections in Web.config file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • WFB

    configSections in Web.config file

    Hi

    I have an application with a couple of referenced assemblies. The
    referenced assemblies and my application all share a few configuration
    settings with the same name but different values. Is there a way to set up
    the config file to recognize this? Im thinking section name elements, but
    am not having much luck. Lets say the project has a StoreLocator assembly,
    a ProductGuide assembly and the main web site. All three have a value in
    thier individual config files named "connectionStri ng", and in each case
    this value is different. When the web site references them, they read the
    "connectionStri ng" value from the master (for lack of a better term)
    applications config file. I would like to set up this config file somehow
    where I can store three "connectionStri ng" values, but each assembly knows
    which value belongs to it.

    Something like this is how I would envision it working

    <configuratio n>
    <configSections >
    <section name="Sales" type="MyCompany .Sales"/>
    <section name="CustomerS ervice"
    type="MyCompany .CustomerServic e"></section> <!-- name of assemby -->
    </configSections>

    <!-- information for the current application -->
    <appSettings>
    <add key="connection String"
    value="server=M yServer;databas e=location;uid= user;pwd=passwo rd"></add>
    <add key="LogPath" value="c:\temp\ "></add>
    <add key="PreCache" value="True"></add>
    <add key="LimitSearc hBySection" value="50"></add>
    </appSettings>

    <!-- information for the MyCompany.Sales dll -->
    <Sales>
    <add key="connection String"
    value="server=S alesServer;data base=Sales;uid= Salesuser;pwd=p assword"></add>
    </Sales>

    <!-- information for the MyCompany.Custo merService dll -->
    <Sales>
    <add key="connection String"
    value="server=C SServer;databas e=Sales;uid=css user;pwd=passwo rd"></add>
    </Sales>

    </configuration>


    Thanks for any help or insight.
    Joe


  • Todd Bellamy

    #2
    Re: configSections in Web.config file

    Have you tried putting the referenced assemlies in thier own folders and
    giving them thier own config files?

    "WFB" <x@hotmail.co m> wrote in message
    news:O%23pZiUuo DHA.1672@TK2MSF TNGP09.phx.gbl. ..[color=blue]
    > Hi
    >
    > I have an application with a couple of referenced assemblies. The
    > referenced assemblies and my application all share a few configuration
    > settings with the same name but different values. Is there a way to set[/color]
    up[color=blue]
    > the config file to recognize this? Im thinking section name elements, but
    > am not having much luck. Lets say the project has a StoreLocator[/color]
    assembly,[color=blue]
    > a ProductGuide assembly and the main web site. All three have a value in
    > thier individual config files named "connectionStri ng", and in each case
    > this value is different. When the web site references them, they read the
    > "connectionStri ng" value from the master (for lack of a better term)
    > applications config file. I would like to set up this config file somehow
    > where I can store three "connectionStri ng" values, but each assembly knows
    > which value belongs to it.
    >
    > Something like this is how I would envision it working
    >
    > <configuratio n>
    > <configSections >
    > <section name="Sales" type="MyCompany .Sales"/>
    > <section name="CustomerS ervice"
    > type="MyCompany .CustomerServic e"></section> <!-- name of assemby -->
    > </configSections>
    >
    > <!-- information for the current application -->
    > <appSettings>
    > <add key="connection String"
    > value="server=M yServer;databas e=location;uid= user;pwd=passwo rd"></add>
    > <add key="LogPath" value="c:\temp\ "></add>
    > <add key="PreCache" value="True"></add>
    > <add key="LimitSearc hBySection" value="50"></add>
    > </appSettings>
    >
    > <!-- information for the MyCompany.Sales dll -->
    > <Sales>
    > <add key="connection String"
    >[/color]
    value="server=S alesServer;data base=Sales;uid= Salesuser;pwd=p assword"></add>[color=blue]
    > </Sales>
    >
    > <!-- information for the MyCompany.Custo merService dll -->
    > <Sales>
    > <add key="connection String"
    > value="server=C SServer;databas e=Sales;uid=css user;pwd=passwo rd"></add>
    > </Sales>
    >
    > </configuration>
    >
    >
    > Thanks for any help or insight.
    > Joe
    >
    >[/color]


    Comment

    • WFB

      #3
      Re: configSections in Web.config file

      Is this possible to do through the IDE? Any time I add a refeence it adds
      it to the /bin folder.

      Thanks
      Joe

      "Todd Bellamy" <toddbellamy@ho tmail.com> wrote in message
      news:Y4Rpb.1391 86$7B1.138408@n ews04.bloor.is. net.cable.roger s.com...[color=blue]
      > Have you tried putting the referenced assemlies in thier own folders and
      > giving them thier own config files?
      >
      > "WFB" <x@hotmail.co m> wrote in message
      > news:O%23pZiUuo DHA.1672@TK2MSF TNGP09.phx.gbl. ..[color=green]
      > > Hi
      > >
      > > I have an application with a couple of referenced assemblies. The
      > > referenced assemblies and my application all share a few configuration
      > > settings with the same name but different values. Is there a way to set[/color]
      > up[color=green]
      > > the config file to recognize this? Im thinking section name elements,[/color][/color]
      but[color=blue][color=green]
      > > am not having much luck. Lets say the project has a StoreLocator[/color]
      > assembly,[color=green]
      > > a ProductGuide assembly and the main web site. All three have a value[/color][/color]
      in[color=blue][color=green]
      > > thier individual config files named "connectionStri ng", and in each case
      > > this value is different. When the web site references them, they read[/color][/color]
      the[color=blue][color=green]
      > > "connectionStri ng" value from the master (for lack of a better term)
      > > applications config file. I would like to set up this config file[/color][/color]
      somehow[color=blue][color=green]
      > > where I can store three "connectionStri ng" values, but each assembly[/color][/color]
      knows[color=blue][color=green]
      > > which value belongs to it.
      > >
      > > Something like this is how I would envision it working
      > >
      > > <configuratio n>
      > > <configSections >
      > > <section name="Sales" type="MyCompany .Sales"/>
      > > <section name="CustomerS ervice"
      > > type="MyCompany .CustomerServic e"></section> <!-- name of assemby -->
      > > </configSections>
      > >
      > > <!-- information for the current application -->
      > > <appSettings>
      > > <add key="connection String"
      > > value="server=M yServer;databas e=location;uid= user;pwd=passwo rd"></add>
      > > <add key="LogPath" value="c:\temp\ "></add>
      > > <add key="PreCache" value="True"></add>
      > > <add key="LimitSearc hBySection" value="50"></add>
      > > </appSettings>
      > >
      > > <!-- information for the MyCompany.Sales dll -->
      > > <Sales>
      > > <add key="connection String"
      > >[/color]
      >[/color]
      value="server=S alesServer;data base=Sales;uid= Salesuser;pwd=p assword"></add>[color=blue][color=green]
      > > </Sales>
      > >
      > > <!-- information for the MyCompany.Custo merService dll -->
      > > <Sales>
      > > <add key="connection String"
      > > value="server=C SServer;databas e=Sales;uid=css user;pwd=passwo rd"></add>
      > > </Sales>
      > >
      > > </configuration>
      > >
      > >
      > > Thanks for any help or insight.
      > > Joe
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...