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.
我有一个应用程序,我在Visual Studio 2010的Windows 7上使用安装程序部署。程序在Windows 7和XP上部署并运行良好,但是当我在Windows 8系统上部署它时,我就会在访问配置文件时出错。
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)
该程序安装在c:programfiles (x86)[公司名称][App名]\,被引用的文件是一个temp文件,它的名称是由Windows GetTempFile生成的,例如x4q0toqw.tmp。该文件夹中不存在该文件,然后还有exe配置文件的引用(myapp.exe)。配置,确实存在)
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.
如果我在Windows 8系统上构建并运行代码,它会安装并运行良好,我不会得到错误,但是如果我在Windows 7上部署了Window 8编译的应用程序,我就会在访问配置文件时遇到同样的错误。这两台机器都是64位的,但是会生成一个32位的应用程序。
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.
我不打算发布两个二进制文件。有人能告诉我发生了什么吗?我正在尝试设置JIT调试,以便在它抛出异常时可以附加到exe上,因为在我没有得到异常的情况下,它本身并没有帮助我。
Thanks,
谢谢,
Gary
加里
This is on two different machines, but I login to the same domain as the same user on both, and am an administrator.
这是在两台不同的机器上的,但是我在这两种机器上登录到相同的域,并且是一个管理员。
3 个解决方案
#1
4
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.
也许你的应用程序在加载过程中重写了你的应用程序配置,这会导致系统质疑访问授权……如果是这样,您可以更改应用程序的属性(已安装的)以拥有管理员权限……这将使您的应用程序自动拥有编程编辑app配置的权利。
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...
还是……您可以忘记应用程序配置重写并将所有内容放入默认的应用程序配置脚本中。但是这会暴露您的应用程序数据库安全性……
#2
0
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.
我犯了同样的错误。这是因为temp文件的创建是在c:2的程序文件中创建的,即x86\[公司名称]\[App名称]文件夹,而普通用户(PC名称\用户)没有权限修改这个文件夹。只要我添加了修改权限,它就开始正常工作了。
#3
0
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:
我在Visual Studio 2010中解决了一个非常类似的问题,通过提升我的服务运行时的帐户特权,获得了Win 7。看到步骤9:
Set the
Account
property toLocalSystem.
将帐户属性设置为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.
当我的serviceProcessInstaller1在LocalService帐户下运行时,我遇到了像您这样的错误。但是将帐户更改为LocalSystem解决了这个问题。然后,我的安装服务就可以写到它的c:)程序文件文件(公司名称)\[App名称]\[App名称].exe。配置文件。这是在我运行服务的安装程序时,只检查我的复选框的安装。
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.LocalSystem值定义了一个高度特权的帐户,但是大多数服务不需要这样高的特权级别。
#1
4
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.
也许你的应用程序在加载过程中重写了你的应用程序配置,这会导致系统质疑访问授权……如果是这样,您可以更改应用程序的属性(已安装的)以拥有管理员权限……这将使您的应用程序自动拥有编程编辑app配置的权利。
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...
还是……您可以忘记应用程序配置重写并将所有内容放入默认的应用程序配置脚本中。但是这会暴露您的应用程序数据库安全性……
#2
0
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.
我犯了同样的错误。这是因为temp文件的创建是在c:2的程序文件中创建的,即x86\[公司名称]\[App名称]文件夹,而普通用户(PC名称\用户)没有权限修改这个文件夹。只要我添加了修改权限,它就开始正常工作了。
#3
0
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:
我在Visual Studio 2010中解决了一个非常类似的问题,通过提升我的服务运行时的帐户特权,获得了Win 7。看到步骤9:
Set the
Account
property toLocalSystem.
将帐户属性设置为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.
当我的serviceProcessInstaller1在LocalService帐户下运行时,我遇到了像您这样的错误。但是将帐户更改为LocalSystem解决了这个问题。然后,我的安装服务就可以写到它的c:)程序文件文件(公司名称)\[App名称]\[App名称].exe。配置文件。这是在我运行服务的安装程序时,只检查我的复选框的安装。
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.LocalSystem值定义了一个高度特权的帐户,但是大多数服务不需要这样高的特权级别。