![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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. > renamed to yourprogram.exe.config and copied to the build output directory. Is that the file that you're changing? |
My System Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||