Daniel,
Well, personally, I would have two separate config files (just like you
have two separate binaries) which have two separate connection strings.
You could have a preprocessor statement for a constant which sets
different values based on the build type. However, that means you would
have to put both values into your config file. That's a little hokey to me,
and it's easier to just have two config files, IMO, as you don't want to
distribute the debug connection string in the release file.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> How can I switch connection strings stored in config file based on the
> build
[quoted text clipped - 6 lines]
>
> Daniel
Daniel - 24 Aug 2007 02:22 GMT
Thanks Nicholas. I think your approach can work. But for me, it's a little
bit inconvenient, as our application is still growing quickly, the config
file changes all the time, lots of stuffs from the enterprise library. Keep
two or more config files be synchronized could be error prone. Can I just
seperate a little part of the config file and make two of them to adopt
different configurations?
Daniel
Steven Cheng[MSFT] - 24 Aug 2007 04:14 GMT
Hi Daniel,
Start from .net framework 2.0, most of the configuration sections in
application config file(app.config or web.config) supply a "configSource"
attribute. This attribute can let you separate the configure section of
that certain section out of the main configuration file. Thus, if you have
multiple configuration fragment (for that certain section) according to
different deployment scenario, you can only modify the separate file. Here
is a blog article introducing this feature:
#Using configSource to split configuration files
http://weblogs.asp.net/fmarguerie/archive/2007/04/26/using-configsource-to-s
plit-configuration-files.aspx
the following msdn document also mentioned this:
#SectionInformation.ConfigSource Property
http://msdn2.microsoft.com/en-us/library/system.configuration.sectioninforma
tion.configsource.aspx
Hope this helps some.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Daniel - 24 Aug 2007 04:20 GMT
Thanks Steven, that's what I want.
Daniel
Steven Cheng[MSFT] - 24 Aug 2007 04:57 GMT
You're welcome!
Enjoy it! :)
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
m.divyam@gmail.com - 11 Sep 2007 10:26 GMT
> Thanks Nicholas. I think your approach can work. But for me, it's a little
> bit inconvenient, as our application is still growing quickly, theconfig
[quoted text clipped - 4 lines]
>
> Daniel
Hi Daniel,
i have another requirement. i need a config file in which i can define
appSettings.
but with the above one i am not able to do that..can you help me
regarding this.
if possible can you let me know how to define connection string
property also in the custom config file