如何强制我在 Visual Studio 2013 中的项目始终以管理员身份运行? [英] How to force my project in Visual Studio 2013 to always run as Administrator?
问题描述
我在 Visual Studio 2013 中有一个 WPF 项目,这个项目有两个按钮.第一个按钮表示启动服务,第二个按钮表示停止服务.当我以管理员身份运行 Visual Studio 时,按钮工作.但是当我在没有权限的情况下打开我的 Visual Studio 时,会出现 InvalidOperationException 异常.
I have a WPF project in Visual Studio 2013, this project have two buttons. The first button say Start Service and the second say Stop Service. When I run my Visual Studio as Administrator, the buttons work. But when I open my Visual Studio without privilages, the InvalidOperationException exception appear.
当 Visual Studio 不以管理员身份运行时,如何强制我的项目以特权启动?
How to force my project start with privilages when Visual Studio doesn't run as administrator?
我将 app.manifest 添加到我的项目并更改为
I added app.manifest to my project and change for
level="requireAdministrator" uiAccess="false"/>
level="requireAdministrator" uiAccess="false"/>
但它不起作用.
为了启动或停止我的服务,我使用了 ServiceController.
For start or stop my service, I am using ServiceController.
推荐答案
这很有趣,看来您需要更改项目运行方式的权限,请尝试执行以下操作
This is interesting and it seems you need to change permissions of how the project runs, Try doing the following
- 转到项目属性>安全性
- 启用单击一次安全设置并选择完全信任应用程序
更多信息在这个链接WPF 安全
这篇关于如何强制我在 Visual Studio 2013 中的项目始终以管理员身份运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!