WPF 应用程序清单文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17406751/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 09:07:06  来源:igfitidea点击:

WPF application manifest file

c#wpfmanifest

提问by mathinvalidnik

I have a WPF application that I want to make it able to start always as an Adminstrator.I've been reading a lot about it and it seems that I have to create my own manifest file and pass it ot the Application properties so on runtime int starts as an Administrator.

我有一个 WPF 应用程序,我想让它始终以管理员身份启动。 int 以管理员身份启动。

The application itself loads a file and sometimes the file might demands administrator access so it can be modified.That is why I am looking for a way after the Application gets installed to be able always to get started in administrator mode.

应用程序本身加载一个文件,有时该文件可能需要管理员访问权限,以便可以对其进行修改。这就是为什么我正在寻找一种在应用程序安装后始终能够以管理员模式启动的方法。

回答by Smartis

To add a Manifest click righton your project fileon the Solution Explorer:

要添加清单,解决方案资源管理器右键单击您的项目文件

  1. Select Add

  2. New item

  3. Choose Application Manifest File

  1. 选择添加

  2. 新物品

  3. 选择应用程序清单文件

File is named app.manifestand don't rename it.

文件名为app.manifest,请勿重命名。



You have to change the element in your Manifestto start always as an Adminstrator:

您必须更改清单中的元素以始终以管理员身份启动:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />


BTW: Good Article for this Question

顺便说一句:这个问题的好文章

http://msdn.microsoft.com/en-us/library/ms742884.aspx

http://msdn.microsoft.com/en-us/library/ms742884.aspx

回答by KyleMit

In Visual Basic, the project properties are structured a little differently. If you find this question and you're in VB in VS2010, follow these instructions to generate an app.manifestfile.

在 Visual Basic 中,项目属性的结构略有不同。如果您发现这个问题并且您在 VS2010 中使用 VB,请按照这些说明生成一个app.manifest文件。

  1. To create an app.manifestfile, go to your project, and select properties. Then click on View Window Settings, under the Applicationtab.
    • ViewWindowSettings
  2. This should generate and open the app.manifestfile, which is saved in your My Project Folder
    • app.manifest
  1. 要创建app.manifest文件,请转到您的项目,然后选择属性。然后单击应用程序”选项卡下的“查看窗口设置”
    • 视窗设置
  2. 这应该生成并打开app.manifest文件,该文件保存在我的项目文件夹中
    • 应用程序清单

Further Reading:WPF MessageBox window style

进一步阅读:WPF MessageBox 窗口样式