Is it possible to add conditions in app.开发者_如何学Pythonconfig file?
I do below in the C# code and I want to do something similar in my app.config
file too.
#if (Debug)
.......
#else
.....
#endif
You can try some type of app.config
transforms like this: http://fknut.blogspot.com/2009/11/appconfig-transformation-with-new.html.
Or have multiple app.config
files like app.config.debug
and app.config.release
, and use the appropriate one in your build.
That is not possible, although in Visual Studio 2010 there is a feature that lets you apply configuration-dependent transformations to the Web.config file, but only when publishing using msdeploy.
There is no such transformation for executable applications. You might want to look into using a post-build action to copy a release or debug config file.
You should be able to do something like this programatically, by putting the relevant sections in two different config files, then at app-start time, load the appropriate config file. The majority of your config would be in the main app.config, and there would be a second config file for the rest.
I don't have the syntax offhand, but it's basically the same idea as having a user.config with user-specific configurations.
精彩评论