Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have an application which I deploy using a setup program in Visual Studio 2010 on Windows 7. The program deploys and runs fine on Windows 7 and XP, but when I deploy it on a Windows 8 system I get errors about access to a configuration file.

The program gets installed in c:\Program Files (x86)[Company Name][App Name]\ and the file being referenced is a temp file with a name that looks machine generated by Windows GetTempFile, e.g. x4q0toqw.tmp. which does not exist in this folder and then there is a reference to the exe config file (myapp.exe.config, which does exist)

If I build and run the code on the Windows 8 system it installs and runs fine, I don't get the error, but then if I deploy the Window 8 compiled app on Windows 7 I get the same errors about access to the configuration file. Both machines are 64-bit but generate a 32-bit application.

I don't plan on releasing two binaries. Can anyone tell me what is going on? I'm in the process of trying to setup JIT debugging to that I can attach to the exe when it throws exceptions, since debugging it natively doesn't help me as I don't get the exceptions.

This is on two different machines, but I login to the same domain as the same user on both, and am an administrator.

like image 598
Gary Avatar asked Nov 12 '12 13:11

Gary


2 Answers

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...

like image 60
genworx Avatar answered Oct 01 '22 12:10

genworx


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.

like image 43
Pabitra Dash Avatar answered Oct 01 '22 10:10

Pabitra Dash