Error occurred loading a configuration file: Access to path c:\\Program Files (x86)\\… denied

送分小仙女□ 提交于 2019-12-05 10:32:08
genworx

Maybe your application is rewriting your app config during the load and this will cause the system to question the access grants... if so, may be you can change the properties of your application (the installed one) to have administrator rights... This will give your application to automatically have the right to programatically edit the app config.

OR... you can just forget about the app config rewriting and put everything in the default app config script. but this will expose your application database security...

Pabitra Dash

I had the same error. This is because the temp file gets created in C:\Program Files (x86)\[Company Name]\[App Name] folder and the normal Users (PC Name\Users) don't have the permission to modify this folder. As soon as I added modify permission, it started working fine.

I resolved a very similar problem in Visual Studio 2010 on Win 7 by elevating the account privileges that my service ran under. See step 9 here:

Set the Account property to LocalSystem.

When my serviceProcessInstaller1 ran under LocalService account I got an error like yours. But changing the account to LocalSystem fixed this issue. My installed service was then able to write to its C:\Program Files (x86)\[Company Name]\[App Name]\[App Name].exe.Config file. This was even though the install for Just me checkbox was checked when I ran the service's setup program.

Bear in mind the remarks here though:

The LocalSystem value defines a highly privileged account, but most services do not require such an elevated privilege level.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!