Vincenzo Lo Palo
Vincenzo Lo Palo

Reputation: 1381

How hide .exe.config or change location?

I need set hidden .exe.config that actually resides in application folder. Alternatively, it would good change folder location, example in application data (hidden folder).

Upvotes: 0

Views: 2217

Answers (1)

Hans Passant
Hans Passant

Reputation: 941237

You cannot change the location of the app.exe.config file with the default CLR host. It initializes the primary appdomain with the values it finds in the .config file before your code starts running. There's only one place it will look for the file, in the same directory as the startup EXE, using the name of the EXE. Altering the location is technically possible but only if you write a custom CLR host that uses a custom AppDomainManager. Writing a custom CLR host requires COM code written in C++. This otherwise defeats the point of having only a single deployable file.

If you intend to do this to hide sensitive information, like the username+password for a dbase connection string, then keep in mind that security through obscurity is not true security.

If you intend to do this to achieve single-file deployment then don't forget to overlook the standard solution: a single file named setup.exe

Upvotes: 3

Related Questions