.NET MAUI- Windows上的管理特权
在Visual Studio Preview中使用.NET MAUI,我无法运行需要管理员特权的Windows应用程序的内容。
我尝试了以下操作:
- 开放Visual Studio预览为管理员
- 设置App.Manifest和.csproj,with:
app.manifest
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<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>
</assembly>
.csproj
<ApplicationManifest>app.manifest</ApplicationManifest>
我有一个非常相似的WPF应用程序,如果您在.NET 6中也运行,如果您在.NET 6中运行,如果您在其中工作,如果您可以使用,如果您可以使用。作为管理员运行Visual Studio。
Using .Net MAUI in Visual studio preview i am unable to run things that require administrator privileges for a Windows application.
I have tried the following:
- Open Visual studio preview as an administrator
- Setup app.manifest and .csproj with the following:
app.manifest
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<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>
</assembly>
.csproj
<ApplicationManifest>app.manifest</ApplicationManifest>
I have a very similar WPF application, that also runs in .net 6 where admin privileges works if you run Visual studio as an administrator.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在正确的轨道上,但需要另一种成分。用文本编辑器打开
package.appxmanifest
文件,并确保dablesials
节点看起来像这样,我添加了
允许eLeelevation
一个。然后在您的
app.manifest
在assembly下添加此部分
节点,您可以根据需要调整级别。看来,如果将
uiaccess
设置为不支持的true。此外,高程仅从Winappsdk 1.1+和:Windows 10- 2022年5月10日至2022年5月10日-KB5013942(OS构建19042.1706,19043.1706,19043.1706,和19044.1706,和19044.1706 href =“ https://learn.microsoft.com/windows/windows/windows-app-sdk/stable-channel#elevation“ rel =” nofollow noreferrer“ Windows-App-SDK/稳定通道#高程
You're on the right track but you need another ingredient. Open the
package.appxmanifest
file with a text editor and make sure that theCapabilities
node looks like thisI've added the
allowElevation
one.Then in your
app.manifest
add this part right under theassembly
nodeYou can tweak the level as needed. It seems that if you set the
uiAccess
to true that is not supported. Also, elevation is only available from WinAppSdk 1.1+ and on:See: https://learn.microsoft.com/windows/apps/windows-app-sdk/stable-channel#elevation