Click here to Skip to main content
Click here to Skip to main content

Custom Application Configuration XML files Warning

By , 21 Jun 2010
 
On a recent application I wrote, I ran into some problems when the application was released onto end users systems, but did not show up any problems in the development environment.
 
The application uses a Class that is serialized and deserialized to/from disk to stores the applications configuration settings. This way, if we want to change the database server/database userid/passwords, we can send an update config file to the user and they can drop this into the applications folder.
 
The application does not make use of the settings management built into the .NET Framework.
 
When the application was deployed to the end user environment at runtime, it generated an exception "Configuration system failed to initialize". I couldn't for the life of me work out what was happening, when the application was executed in the development environment, there were no errors, and everything worked as expected.
 
So, what was the problem.....simple, a filename conflict.
 
Originally I had used AppName.config as the settings file, changed this to AppName.xml and everything works now. As a test, I created an empty file named AppName.config, and dropped it in the EXE folder and yes, it triggered the exception.
 
It appears that if a file named AppName.config appears in the EXE folder, it attempts to start the configuration subsystem and throws the "Configuration system failed to initialize" error.
If you name a file AppName.exe.config and drop it in the EXE folder, it throws an exception with "The application has failed to start because its side-by-side configuration is incorrect".
This is despite not using any settings within the MyProject Application Settings tab.
 
Leasson Learnt: If you are making use of custom files to store config settings, don't call them AppName.config or AppName.exe.config.
 
Oh, and AppName should be replaced with whatever your EXE filename is...... :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

DaveAuld
Engineer Apache North Sea Ltd.
United Kingdom United Kingdom
Member
I have been working in the Oil & Gas Industry for over 20 years now.
 
Core Discipline is Instrumentation and Control Systems.
 
Completed Bsc Honours Degree (B29 in Computing) with the Open University in 2012.
 
Currently, Offshore Installation Manager for the Forties Charlie Platform, which is located ~110Miles NE of Aberdeen, Scotland in the North Sea.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 21 Jun 2010
Article Copyright 2010 by DaveAuld
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid