VS2008 C#用manifest提升程序权限后,调试时还是不行,求解

C#程序中添加app.mainifest,修改其中项使之提升为管理员权限,
之后,应用程序的清单自动变成Properties\app.manifest,也就是说起作用了。
debug目录下的exe程序,双击打开时会提示需要管理员权限,点击确定即可管理员权限打开。
打开vs2008,调试此程序时也会提示需要用管理员权限打开vs2008才能调试此程序。
但是,当F5运行时,没有提示需要管理员权限,程序也没有在管理员权限下运行(由于程序中有全局钩子,钩子有没有起作用很容易看出有没有在管理员权限下运行)。求解决方法,双击exe运行时,钩子是有用的,但点按钮或者F5调试运行时,钩子就无法起作用,求解释,求解决方法。

F5键启动的是 <你的程序名>.vshost.exe
和双击时不同
你需要修改安装钩子的代码以适应文件名
我遇到过这个问题

当然,你可以通过项目属性设置不使用vs宿主来调试
但这回使部分调试功能不可用
比如编辑并继续等
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-04-13
看看你的文件内容和我的一样不,我的是可以提示需要管理员权限才能运行的
另外的是VS2010

<?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.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator"
uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"
ID="Custom"
SameSite="site" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
</application>
</compatibility>
</asmv1:assembly>
相似回答