如何在 Visual Studio 2010 中编译时嵌入清单文件
我有一个项目,其清单文件具有以下节点:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
...这意味着我希望它默认仅以“管理员身份”运行。
通过四处搜索,为了使这项工作有效,我有两个选择:
- “嵌入”它。
- 使用 exe 部署清单文件,并将其命名为 YourProject.exe.manifest。
我已经尝试过选项 2,当我运行我的应用程序时,它不要求管理员权限?
那么,我该如何在VS2010中执行选项1呢?我听说过 mt.exe,但这对我来说没有好处,因为它是在构建后完成的。我需要解决方案的一部分和项目文件本身的选项。
那么,我该如何进行这项工作呢?我很乐意做2,但似乎不起作用?
I have a project with a manifest file with the following node:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
...meaning I want it to only run "as administrator" by default.
from searching around, to make this work I have two options:
- "Embed" it.
- deploy the manifest file with the exe, and name it YourProject.exe.manifest.
I've tried option 2, and when I run my app it doesn't ask for admin rights?
So, how do I do option 1 in VS2010? I've heard of mt.exe, but this is no good to me as it's done post build. I need the option to part of the solution and the project file itself.
So, how do I make this work? I'll be happy to do 2, but it doesn't seem to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Visual Studio 2010 中,新项目的默认设置是将清单嵌入到应用程序中(选项 #1)。默认情况下,虽然包含默认清单。您需要做的是添加自定义清单。
这会将名为 app.manifest 的文件添加到项目中。打开该文件并将该行修改为以下内容
这也应该适用于 Visual Studio 2008。
In Visual Studio 2010 the default setting for a new project is to embed the manifest in the application (option #1). By default though a default manifest is included. What you need to do is add a custom manifest.
This will add a file named app.manifest to the project. Open that file and modify the line to be the following
This should also work in Visual Studio 2008.
在VS2010下有点不同。右键单击项目并选择属性。选择“应用程序”选项卡,然后单击“查看 Windows 设置”。这将打开清单。然后进行您需要的更改。
Under VS2010 it is a little different. Right click the Project and select Properties. Select the "Application" tab and then click "View Windows Settings". This opens the manifest. Then make the changes you need.
我刚刚遇到了将现有的 app.manifest 复制到另一个项目(C#)中引起的相同问题。
我通过卸载项目、编辑其 csproj 文件并插入以下部分来修复此问题:
这使我的应用程序能够正确获取 app.manifest。
I just ran into the same problem caused by copying an existing app.manifest into another project (C#).
I fixed it by unloading the project, editing its csproj file and inserting the following section:
This allowed my application to pick up the app.manifest correctly.