1

Is it save to rename an (entry) assembly (.exe) including it´s configuration file (.config) afterwards? May the .net runtime throw an exception, cause the name is diffrent that the name it was build with?

There are no other assemblies that have dependencies on this file.

The use case is that we run our programm multiple times in our hosting environment as service and we want to identify the programms better in the TaskManager (Internal Support) by including the company name in the file name of the .exe.

Normal name by Build process:

OurApplication.exe
OurApplication.exe.config

New name by Installation process:

OurApplication.CompanyName.exe
OurApplication.CompanyName.exe.config

I have tried this manually once and it seemed to work, but I am unsure if I have missed something.

Jehof
  • 34,674
  • 10
  • 123
  • 155
  • Renaming it should also change the default settings save location for each copy, so they work on different user settings, [confer this answer](http://stackoverflow.com/a/621295/2718186). – MicroVirus Mar 15 '16 at 10:52
  • The EXE file is special, nobody but the user ever tries to find it. You can't get a warranty for "hosting environment". – Hans Passant Mar 15 '16 at 16:06

1 Answers1

3

Nope, there's no problem doing so. It works perfectly fine unless there's a hard-coded reference to the executable name somewhere.

As explained in the MSDN (bold is mine):

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.

Update: as @MicroVirus pointed out in the comments, you may have problems if you store user settings in the default location, which uses AppDomain.CurrentDomain.FriendlyName which defaults to the exe name. But in your case, being the installer the one changing the name, it should be no problem (the user settings will be stored in the correct path once they are saved)

Community
  • 1
  • 1
Jcl
  • 27,696
  • 5
  • 61
  • 92