2011-05-18 242 views
50

我有这样的代码从一个同事(从网络的某个地方可能得到它),但他外出度假,我需要把它添加到清单文件如何创建/编辑Manifest文件?

<?xml version="1.0" encoding="utf-8" ?> 
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" 
    xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" 
    xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <assemblyIdentity version="1.0.0.0" name="MyApplication" /> 
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> 
     <security> 
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> 
       <requestedExecutionLevel level="requireAdministrator" 
     uiAccess="false" /> 
      </requestedPrivileges> 
     </security> 
    </trustInfo> 
</asmv1:assembly> 

我是比较新的这个所以任何帮助会不胜感激。 感谢

我使用Visual Studio 2010

+1

可能的重复[如何强制C#应用程序以管理员身份在Windows 7上运行](http://stackoverflow.com/questions/2818179/how-to-force-c-app-to-run-as-administrator -on-windows-7) – 2011-05-18 20:39:31

回答

69

在VS2010,2012年,2013年和2015年,你可以在清单文件添加到项目中。在上右键单击您的项目文件解决方案资源管理器,选择Add,然后选择New item。在那里你可以找到Application Manifest File

文件名是app.manifest

+0

谢谢,但我不知道如何正确创建文件。 – 2011-05-19 13:22:45

+0

Ibram的说明也适用于Visual Studio 2012. – WorkSmarter 2013-10-31 22:28:04

+2

和Visual Studio 2013。 – buttercup 2014-07-12 18:20:26

9

由于IBRAM指出,添加清单直通解决方案资源管理器:

enter image description here

这将创建一个缺省清单。现在,编辑清单。

  • 将assemblyIdentity名称更新为您的应用程序。
  • 要求用户信任你的应用程序

enter image description here

  • 添加支持的操作系统

enter image description here

+3

''节点不是默认的吗?是你添加了什么原因的吗?我正在使用VS2015 – Horizon 2016-08-11 08:52:32

0

转到OBJ文件夹中你的应用程序文件夹,然后调试。在那里删除清单文件并重新构建。 它为我工作。