I learned a valuable lesson today about naming configuration files for my programs. When I started building.NET applications I followed the .NET convention for naming program configuration files: MyProgram.exe.config
These days I write less .NET applications and more native Windows applications using Delphi. I continue using the .NET naming convention for configuration files for all my programs even native Windows applications. This hasn’t been a problem until today.
Today I embedded a manifest into a program and when I ran the program I got the following error message:
This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
Without the manifest the program ran fine, but the program failed each time the manifest was included. I first thought a problem was with the manifest. I review the manifest over, and over, and over again. I even used a manifest from another application that does not have the problem. After banging my head on the wall for a couple of hours I found the source of the problem, and it wasn’t the manifest at all.
Like all my programs, this particular program creates a configuration file using the .NET naming convention MyProgram.exe.config. But in this one case the configuration file is stored in the same directory as the program file, and here in lies the problem.
Apparently Windows XP, and I assume Vista as well, expects the program configuration file to be based on some specific config file schema when the manifest is embedded in the program file even if the program is a native Windows program. I knew this to be true with .NET applications but I didn’t realize the same is true for native Windows applications.
I have not spent time figuring out the expected schema. I suspect it is the .NET config file schema, but I now follow a new naming convention. I do not name my config files MyProgram.exe.config any more. Instead I use MyProgram.config, which does not have any negative side effects when stored in the same directory as the program file.
Update: If you want to use the .NET config file naming convention for your native Windows application, your .config file must be an XML, and the root element must be . Other root elements might be allowed but I know works.
- Retiring My CSV Editor
- Cannot Resolve Machine Name From Mac OS X
- How To Access a Windows 2003 File Share From Mac OS X
- wuauclt svchost and 100% CPU usgage
- PowerPoint 2007 and Outlook 2003 Don't Play Nice Together
- VIsta, Reigstry Keys, and UAC
- Delphi (BDS) Live Templates for SQL Server
- Windows Vista to Support 7,000+ New Native APIs
- Native Windows Code Is Here for a While
- MSDN Wiki