views:

416

answers:

2

...and are there any other caveat for other platforms?

I create an app.config for a win forms project, for example Application.exe.

By default I expect that at runtime my application is going to look for a file called Application.exe.config.

But there seem to be exceptions to this, for example in a Windows Server 2003 environment an app will look for Application.config.

The full path of the config file being searched for is different in Windows Server 2003, why is this?

Where is the definition for these cosmic app.config loading rules?

+1  A: 

From MSDN :

The name and location of the application configuration file depend on the application's host, which can be one of the following:

Executable–hosted application.

The configuration file for an application hosted by the executable host is in the same directory as the application. The name of the configuration file is the name of the application with a .config extension. For example, an application called myApp.exe can be associated with a configuration file called myApp.exe.config.

And also

For client executables, the application configuration file resides in the same directory as the application's executable and has the same base name as the executable with a .config extension. For example, the configuration file for C:\Program Files\Myapp\Myapp.exe is C:\Program Files\Myapp\Myapp.exe.config.

mathieu
Thanks. While this is not incorrect, my question arises from the fact that there are exceptions to the behavior outlined here. If it really was as simple as this I would not be running into problems. See original question for a clarification.
Dan
+1  A: 

I don't have the details at hand, but I believe a service pack or point version of the .NET Framework allowed ExeName.config to be an option, and that is now still supported for backward compatibility, but more recent service packs have returned to defaulting to ExeName.exe.config for all systems.

Mark Hurd