I have a Settings files that is attached to app.config and I'm using pre-Build command line to call a bat file that supposes to override app.config based on the selected configuration for the project (Debug, release ...) before the build process. everything looks good, app.config is get updated on the build time (I can see the changes in settings and app.config). But when I'm trying to get any value in the settings using some command like this:
var test = Settings.Default.DBConn;
BUT... for the first time (that app.config is not get override) everything works fine, but when I'm changing the configuration (let's say from debug to release) an error is throwing that says something is wrong with the xml or something like that, the error is ConfigurationErrorsException, and the message is
The value of the property 'serializeAs' cannot be parsed. The error is: The enumeration value must be one of the following: String, Xml, Binary, ProviderSpecific.
Here is my bat file:
@echo off
if %1==Debug GOTO DE
if %1==DEV GOTO DEV
if %1==Release GOTO PR
:DE
xcopy %2configs\app_Debug.config %2app.config /Y
GOTO END
:PR
xcopy %2configs\app_PROD.config %2app.config /Y
GOTO END
:DEV
xcopy %2configs\app_DEV.config %2app.config /Y
GOTO END
:END
I really don't know what is the problem I checked out these discussions
Overriding App.Config settings
Manage multiple app config files during development
and few more. But I couldn't find any solution. Could you please help me on this! Thanks.