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>
Enable clickone security settings are set to full trust. What am I doing wrong ?
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>
There are a number of possible issues which I have listed in the order I suspect is most likely to less likely.
Possible Problem 1
What are your UAC settings? As detailed in Create and Embed an Application Manifest (UAC)
if you have UAC disabled and you request administrator permissions the
Application might launch but will fail later
Possible Problem 2
There could be something wrong else where in the manifest as the assembly information is required. Posting your whole manifest would help.
Possible Problem 3
You have added the applicationRequestMinimum
node which is not required for UAC escalation. It may be worth dropping that and trying again.
来源:https://stackoverflow.com/questions/1850768/how-to-give-my-c-sharp-app-administrative-rights-manifest-file