I have a windows service which is installed to C:\Windows\System32. It has a usual .config file, where some app settings are stored. I have another app that writes some values to this config. When i run this app it throws an exception at this line
var config = ConfigurationManager.OpenExeConfiguration(serviceExePath);
The exception says: An error occurred loading a configuration file: The parameter ‘exePath’ is invalid. Parameter name: exePath
When I put my windows service to another folder everything is ok! Is it due to some access violation rules or smth like that? Is there any way to use System32 folder for my service and open its config?
OS: Windows 7 x64
It is a poor choice for a file location. That directory belongs to Windows, it isn’t suitable for your own apps. For one, you’ll need admin privileges to open files in that directory. You don’t get that without a manifest to trigger the UAC prompt.
For another, that directory is virtualized on the x64 version of Windows. A 32-bit app trying to access files there will be redirected to c:\windows\syswow64.
I could have been more accurate if you posted the stack trace. But, just don’t do it.