Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - setting a connection string for a Windows Service on production

Reply
 
Old 05-06-2008   #1 (permalink)
Bill Mild


 
 

setting a connection string for a Windows Service on production

Feel free to let me know if there is a better place to post this question

I'm a website developer trying to write a Windows Service, and I think I'm
running into trouble due to the paradigm shift.

In website development, I change the web.config file on the fly without
re-building a project. How does this work with the app.config in a Windows
Service? It seems like when I update a ConnectionString in app.config after
rolling to a production server, it doesn't take. Does app.config get
complied into the executable on build so that I can't change it on the fly?
If so, how would I set it up to be able to configure the db connection string
on the production server?

Thanks.

My System SpecsSystem Spec
Old 05-06-2008   #2 (permalink)
Norman Yuan


 
 

Re: setting a connection string for a Windows Service on production

It depends on how the WIN Service app reads the connectionString from
app.config. If you let the service read app.config at startup only, then you
need to stop and restart the service once the app.config is changed. This is
the common approach. As the developer of the Service, you do know when the
service app reads the settings in app.config, don't you? The best thing to
do is to make sure the ConnectioNString is correct before installing the Win
service in a production box.

If for some reasons that your service can never be stopped once started,
then you could code the service to read the ConnectionString setting in
app.config periodically to see if change has been made, if yes, use the
newly read ConnectionString. However, I doubt its necessity, although it is
technically doable.


"Bill Mild" <wmild@xxxxxx> wrote in message
news:33F2ED98-0CD4-40F0-AA23-659B4F351FCA@xxxxxx
Quote:

> Feel free to let me know if there is a better place to post this question
>
> I'm a website developer trying to write a Windows Service, and I think I'm
> running into trouble due to the paradigm shift.
>
> In website development, I change the web.config file on the fly without
> re-building a project. How does this work with the app.config in a
> Windows
> Service? It seems like when I update a ConnectionString in app.config
> after
> rolling to a production server, it doesn't take. Does app.config get
> complied into the executable on build so that I can't change it on the
> fly?
> If so, how would I set it up to be able to configure the db connection
> string
> on the production server?
>
> Thanks.
My System SpecsSystem Spec
Old 05-06-2008   #3 (permalink)
Bill Mild


 
 

Re: setting a connection string for a Windows Service on productio

Thanks Norman. You basically told me that when I stop and restart the
service, it should re-read the app.config at that point. That is what I
would have expected. There must be something deeper going on. Due to time
constraints, I've opened a case with Microsoft to get this figured out.

Thanks Again,
Bill

"Norman Yuan" wrote:
Quote:

> It depends on how the WIN Service app reads the connectionString from
> app.config. If you let the service read app.config at startup only, then you
> need to stop and restart the service once the app.config is changed. This is
> the common approach. As the developer of the Service, you do know when the
> service app reads the settings in app.config, don't you? The best thing to
> do is to make sure the ConnectioNString is correct before installing the Win
> service in a production box.
>
> If for some reasons that your service can never be stopped once started,
> then you could code the service to read the ConnectionString setting in
> app.config periodically to see if change has been made, if yes, use the
> newly read ConnectionString. However, I doubt its necessity, although it is
> technically doable.
>
>
> "Bill Mild" <wmild@xxxxxx> wrote in message
> news:33F2ED98-0CD4-40F0-AA23-659B4F351FCA@xxxxxx
Quote:

> > Feel free to let me know if there is a better place to post this question
> >
> > I'm a website developer trying to write a Windows Service, and I think I'm
> > running into trouble due to the paradigm shift.
> >
> > In website development, I change the web.config file on the fly without
> > re-building a project. How does this work with the app.config in a
> > Windows
> > Service? It seems like when I update a ConnectionString in app.config
> > after
> > rolling to a production server, it doesn't take. Does app.config get
> > complied into the executable on build so that I can't change it on the
> > fly?
> > If so, how would I set it up to be able to configure the db connection
> > string
> > on the production server?
> >
> > Thanks.
>
>
My System SpecsSystem Spec
Old 05-06-2008   #4 (permalink)
John Vottero


 
 

Re: setting a connection string for a Windows Service on productio

"Bill Mild" <wmild@xxxxxx> wrote in message
news:95C9303B-4AEB-4FA0-BAA8-5E00F448B6E9@xxxxxx
Quote:

> Thanks Norman. You basically told me that when I stop and restart the
> service, it should re-read the app.config at that point. That is what I
> would have expected. There must be something deeper going on. Due to
> time
> constraints, I've opened a case with Microsoft to get this figured out.
>
One key difference between app.config and web.config is that app.config gets
renamed to yourprogram.exe.config and copied to the build output directory.
Is that the file that you're changing?


My System SpecsSystem Spec
Old 05-06-2008   #5 (permalink)
Bill Mild


 
 

Re: setting a connection string for a Windows Service on productio

John,

That was exactly the problem. I was changing the app.config in root of the
project, instead of *.exe.config in the release folder.

Thanks,
Bill

"John Vottero" wrote:
Quote:

> "Bill Mild" <wmild@xxxxxx> wrote in message
> news:95C9303B-4AEB-4FA0-BAA8-5E00F448B6E9@xxxxxx
Quote:

> > Thanks Norman. You basically told me that when I stop and restart the
> > service, it should re-read the app.config at that point. That is what I
> > would have expected. There must be something deeper going on. Due to
> > time
> > constraints, I've opened a case with Microsoft to get this figured out.
> >
>
> One key difference between app.config and web.config is that app.config gets
> renamed to yourprogram.exe.config and copied to the build output directory.
> Is that the file that you're changing?
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Help with connection string .NET General
HELP: Setting Up Windows End Of Tivo Serial Connection Vista networking & sharing
HELP: Setting Up Windows End Of Tivo Serial Connection Vista General
HELP: Setting Up Windows End Of Tivo Serial Connection Vista General
HELP: Setting Up Windows End Of Tivo Serial Connection Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46