开发者

What are the different config files in a Windows Service .NET?

When I create a .NET Windows Service, there is an App.config file. When I compile the service, it creates a ServiceName.exe.config in the bin directory and there is开发者_StackOverflow社区 also a ServiceName.vshosts.exe.config

Q1) What is the significance of multiple config files?

When I change a setting in the App.config it does not take effect until I uninstall the service, recompile it and reinstall the service. I tried making the setting change in both App.config as well as ServiceName.exe.config with no luck.

Q2) My understanding was that a config file makes it easier to make setting changes without having to redeploy the service.

Any response is appreciated


App.config is used as a template to create <service>.exe.config and <service>.vshost.exe.config when one does not exist. If it does exist, then visual studio does not overwrite it when you recompile. You can tell vstudio to overwrite it if you want by changing the app.config's properties in vstudio.

<service>.vshost.exe.config is used (unless you tell it otherwise) during debugging.

<service>.exe.config is used when you are not running the debugger.

Where you make the change depends on what environment you want the change reflected in.


The App.config if for the design time. The real .config will be placed by compiler in the bin\Release\ or bin\Debug depending on the build mode you used.

When you install your service using sc.exe or InstallUtil.exe, those tools expect you to have all service files to be in installation directory (directory of your main executable that you pass to those tools).

Any change to your App.config will not be reflected in <servicename>.exe.config until you build your Windows service project. If you need to create installer for your service, the setup project is supposed to deal with those things automagically but very often messes this and other things up. So, if you need an installer, use the http://installer.codeeffects.com or similar services to it. I don't known any free installer-building services, though, but this one is new and relatively cheap.


One is for debugging inside of Visual Studio and the other is for the real service.

The config file has to be deployed to the Windows System directory and your service restarted to pickup the changes.


You can get more details on this url --> http://blogs.msdn.com/dtemp/archive/2004/08/17/215764.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜