![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Sharing Config File Settings I have an ASP.NET application and I need to create a Windows service that is related to it. I would like to share some of the configuration file settings in Web.config between the two. There are configuration items in the <appSettings>, <connectionStrings> and <system.web><mailSettings></system.web> sections that I need to be able to access in the Windows service. I know that some parts of config files allow you to specify an outside file as the source but <connectionStrings> and <systemweb> don't appear to allow this. I could just parse the Web.config file from the Windows service but isn't there some built in support for this? Can you load an external config file somehow? Thanks, Dave |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Sharing Config File Settings One way. "Push out" some of the settings to seperate files. And share the files between projects. Below is what I have in my asp.net project web.config file. You can probably do the same in a winforms app or windows service. <?xml version="1.0"?> <configuration> <appSettings file="CustomAppSettings.config"> </appSettings> <connectionStrings configSource="ExternalConnectionStrings.config" /> </configuration> =========================== **Contents of** ExternalConnectionStrings.config <connectionStrings > <add name="LocalDatabaseInstance" connectionString="server=MyServer;database=MyDatabase;Integrated Security=SSPI; Pooling=false; " providerName="System.Data.SqlClient"/> </connectionStrings> ========================== **Contents of** CustomAppSettings.config <appSettings> <add key="Key1" value="Value1" /> <add key="Key2" value="Value2" /> </appSettings> "headware" <david.k.land@xxxxxx> wrote in message news:54b6a037-ee59-4198-b227-cdf437236e36@xxxxxx Quote: >I have an ASP.NET application and I need to create a Windows service > that is related to it. I would like to share some of the configuration > file settings in Web.config between the two. There are configuration > items in the <appSettings>, <connectionStrings> and > <system.web><mailSettings></system.web> sections that I need to be > able to access in the Windows service. > > I know that some parts of config files allow you to specify an outside > file as the source but <connectionStrings> and <systemweb> don't > appear to allow this. > > I could just parse the Web.config file from the Windows service but > isn't there some built in support for this? Can you load an external > config file somehow? > > Thanks, > Dave |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Sharing Config File Settings On Jul 13, 10:33*am, "sloan" <sl...@xxxxxx> wrote: Quote: > One way. > "Push out" some of the settings to seperate files. *And share the files > between projects. > > Below is what I have in my asp.net project web.config file. > You can probably do the same in a winforms app or windows service. > > <?xml version="1.0"?> > > <configuration> > > <appSettings file="CustomAppSettings.config"> > > </appSettings> > > <connectionStrings configSource="ExternalConnectionStrings.config" /> > > </configuration> > > =========================== > > **Contents of** ExternalConnectionStrings.config > > <connectionStrings > > > <add name="LocalDatabaseInstance" > connectionString="server=MyServer;database=MyDatabase;Integrated > Security=SSPI; Pooling=false; " providerName="System.Data.SqlClient"/> > > </connectionStrings> > > ========================== > **Contents of** CustomAppSettings.config > > <appSettings> > > *<add key="Key1" value="Value1" /> > *<add key="Key2" value="Value2" /> > > </appSettings> > > "headware" <david.k.l...@xxxxxx> wrote in message > > news:54b6a037-ee59-4198-b227-cdf437236e36@xxxxxx > Quote: > >I have an ASP.NET application and I need to create a Windows service > > that is related to it. I would like to share some of the configuration > > file settings in Web.config between the two. There are configuration > > items in the <appSettings>, <connectionStrings> and > > <system.web><mailSettings></system.web> sections that I need to be > > able to access in the Windows service. Quote: > > I know that some parts of config files allow you to specify an outside > > file as the source but <connectionStrings> and <systemweb> don't > > appear to allow this. Quote: > > I could just parse the Web.config file from the Windows service but > > isn't there some built in support for this? Can you load an external > > config file somehow? Quote: > > Thanks, > > Dave "file" and "configSource" attributes are, but the <mailSettings> element doesn't have either one. This solution will get me most of the way there, I was just hoping that there was a more generic, complete solution. Dave |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| file sharing settings in vista | Vista networking & sharing | |||
| what is the web.config file? | Vista General | |||