visual-studio Visual Studio 输出文件权限?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3312646/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio output file permissions?
提问by uray
I'am using Visual Studio 2010, how to set or automatically change owner of the output file from Visual Studio (such as executable file) to user other than administrator?
我正在使用 Visual Studio 2010,如何将输出文件的所有者(例如可执行文件)设置或自动更改为管理员以外的用户?
all output files currently is owned by Administrator (due to Visual studio is launch by administrative privilege), so sometime I can't delete those files due to access permissions.
当前所有输出文件都归管理员所有(由于 Visual Studio 是通过管理权限启动的),因此有时由于访问权限我无法删除这些文件。
sometime visual studio itself can't delete it too (after i ran the executable) until few minutes, its really annoying when I need to rebuild those executable. anyone know what's the actual problem here?
有时visual studio本身也不能删除它(在我运行可执行文件之后)直到几分钟,当我需要重建这些可执行文件时真的很烦人。有谁知道这里的实际问题是什么?
error message is : error LNK1168: cannot open [path to file].exe for writing
错误信息是: error LNK1168: cannot open [path to file].exe for writing
采纳答案by uray
no one give the right answer, so I close this question as a bug within operating system, not in Visual Studio, maybe the O/S is compromised since the file handle is owned by 'System' process (PID 4) and I can't release the file handle since it reporting the file handle is invalid using process explorer.
没有人给出正确答案,所以我将这个问题作为操作系统中的错误关闭,而不是在 Visual Studio 中,也许 O/S 受到损害,因为文件句柄归“系统”进程(PID 4)所有,我可以” t 释放文件句柄,因为它使用进程资源管理器报告文件句柄无效。
回答by Maiku Mori
WoohoI finally figured this one out.
哇哦,我终于想通了这一点。
It's a bug in Windows 7 and likely in Windows Server 2008 (possibly 64bit versions only). It surfaces when you disable Application Experienceservice.
这是 Windows 7 中的错误,也可能是 Windows Server 2008(可能仅 64 位版本)中的错误。当您禁用应用程序体验服务时,它就会出现。
Re-enabling this service has fixed this problem for me.
重新启用此服务已为我解决了这个问题。
You can't imagine how happy I am, this was making programming so frustrating as it's not just messing with VC, but any compiler and to top it off it's quite random.
你无法想象我有多高兴,这让编程变得如此令人沮丧,因为它不仅与 VC 混淆,而且与任何编译器混淆,最重要的是它是非常随机的。
A bit more info hereas to why it's causing a problem.
这里有更多关于它为什么会导致问题的信息。
List of other SO questions which seem to be related:
似乎相关的其他 SO 问题列表:
回答by Ellen
As mentioned above, the fix to this problem is to enable Windows Application Experience Service. Here's how to do this:
如上所述,解决此问题的方法是启用 Windows 应用程序体验服务。以下是如何执行此操作:
- Windows key + R
- Type "services.msc" in the window that pops up
- In the list, find "Application Experience."
- Double-click on this and change from "disabled" to "enabled"
- Windows 键 + R
- 在弹出的窗口中输入“services.msc”
- 在列表中,找到“应用程序体验”。
- 双击它并从“禁用”更改为“启用”
It should work now! Worked for me :)
现在应该可以了!对我来说有效:)
Source: http://www.techknowl.com/disable-unwanted-services-and-speed-up.html
来源:http: //www.techknowl.com/disable-unwanted-services-and-speed-up.html
回答by Mitchel Sellers
Well, the file as it is created will be owned by the creator, if you are running Visual Studio as an administrator you are just stuck with it that way from an owner perspective.
好吧,创建的文件将归创建者所有,如果您以管理员身份运行 Visual Studio,那么从所有者的角度来看,您只能以这种方式使用它。
Personally, unless you are using IIS for Web Applications I find myself running Visual Studio as a regular user more and more frequently, at least with VS 2010.
就个人而言,除非您将 IIS 用于 Web 应用程序,否则我发现自己越来越频繁地以普通用户身份运行 Visual Studio,至少在 VS 2010 中是这样。
In regards to the issue where Visual Studio can not delete the file, I have seen this before with build errors, and sometimes if you have multiple projects that are referencing the same assembly. Your best bet there is try and track down the lock, and then you can either kill the lock, or restart Visual Studio.
关于 Visual Studio 无法删除文件的问题,我之前看到过构建错误,有时如果您有多个项目引用同一个程序集。最好的办法是尝试追踪锁定,然后您可以终止锁定,或重新启动 Visual Studio。
I typically use Process Explorer (From SysInternals) to simply remove the handle on the file. (NOTE: this is NOT a "great" idea, but it works....)
我通常使用 Process Explorer(来自 SysInternals)来简单地删除文件的句柄。(注意:这不是一个“好”的主意,但它有效......)

