c# - exePath is invalid exception in ConfigurationManager.OpenExeConfiguration -


I have a Windows service that is installed on C: \ Windows \ System 32. Its a normal. The config file is where some app settings are stored. I have an app that writes some values ​​in this config. When I run this app, it throws an exception on this line

var config = ConfigManager.OpenExeConfiguration (serviceExEPath);

The exception says: There was an error loading a configuration file: parameter 'exePath' is invalid Parameter name: exePath

When I place my window service in another folder then it's all right! Is there some such violation due to the rules or the mouth? Is there any way to use the System32 folder for my service and to open its config?

OS: Windows 7 X64

A bad choice for this file location is. This directory is related to Windows, it is not suitable for your own application. For one, you will need Administrator privileges to open the file in that directory. You do not get this without triggering to trigger the UAC prompt.

For the second, that directory is virtualized on the x64 version of Windows A 32-bit app trying to access files will be redirected to c: \ windows \ syswow64.

If you post stack trace then I could have been more precise. But, just do not do it.


Comments