Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

For VS 2013 c# Windows service project, change to app.config is not recognized.

$
0
0


In VS 2013 I built a Windows service project that uses a Timer to connect to SQL Sever database and invoke a stored procedure to update the database. It gets the connect string from app.config, everything is working fine.
When I corrupt the connect string (using notepad remove it from app.config) I expect the service to fail, but it does not - it keeps running normally, though it should fail because every interval of one minute it gets the connect string and opens and closes a database connection.
I am adding my error handling logic so the service will fail gracefully with error msg. to event log, etc.
After corrupting the connect string, I tried bouncing the service but it still works fine. I tried bouncing the box and still everything works fine. I tried iisreset and still the service is working fine.
Finally, I did project rebuild from VS 2013 including stop service, rebuild, start service. This was the only way to get the service to fail. btw, In this final step VS asked me if I wanted to reload app.config because it had been changed (this reload is expected behavior in the tool).
Why didn't the service fail right after I changed app.config? Or at leaset ater service bounce or iisreset?  My timer interval is one minute so I do guarantee that it was not a timing issue.
This code gets the connect string from app.config...
string s = ConfigurationManager.ConnectionStrings["ConnectionSS"].ToString();
Thanks very much for any feedback.


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>