如何授予我的 C# 应用程序管理权限?清单文件 [英] How to give my C# app administrative rights? manifest file
问题描述
我的 C# 应用程序使用 win32_networkingadapterconfig 时遇到了一些问题.问题是当我在没有管理员权限的用户上使用该应用程序时,我无法使用 win32_networkingadapterconfig 中的更改功能.我试图以管理员身份运行",但没有运气.我已经尝试在 trustInfo 部分使用此内容制作清单文件:
I'm having some trouble with my C# app that uses win32_networkingadapterconfig. The problem is that I can't use the altering functions in win32_networkingadapterconfig when I use the app on a user that dont have admin rights. I have tried to "run as administrator", but no luck. And I have tried to make a manifestfile with this content in the trustInfo part:
<security>
<applicationRequestMinimum>
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
启用 clickone 安全设置设置为完全信任.我做错了什么?
Enable clickone security settings are set to full trust. What am I doing wrong ?
推荐答案
您的代码段中有一个trustinfo"悬空.让它看起来像这样:
There's a "trustinfo" dangling in your snippet. Make it look like this:
<?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>
</security>
</trustInfo>
</asmv1:assembly>
这篇关于如何授予我的 C# 应用程序管理权限?清单文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!