.NET 嵌入式清单使 XP 崩溃

发布于 2024-08-25 05:11:09 字数 798 浏览 6 评论 0原文

我在 .NET exe 中嵌入了一个清单,以便它可以在 Vista 和 Windows 7 中请求提升权限。我使用的清单如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"  name="ElevationTest" type="win32"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

它在 Vista 和 Windows 7 中按预期工作,但使用标准“. ..遇到问题,需要关闭...”错误。如果我不嵌入任何清单,那么它会按预期工作,但显然在 Vista 和 Windows 7 中不具有所需的权限。

生成 exe 的标准方法是什么,该 exe 将在 XP 和 Vista / Windows 7 中以正确的权限运行?

谢谢, 艾伦

I am embedding a manifest in a .NET exe so that it can request elevated permissions in Vista and Windows 7. The manifest that I am using is as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"  name="ElevationTest" type="win32"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

It works as expected in Vista and Windows 7 but crashes XP with the standard "... has encountered a problem and needs to close..." error. If I don't embed any manifest then it works as expected but will obviously not have the required permissions in Vista and Windows 7.

What is a standard way of producing an exe that will function with the correct permissions in XP and Vista / Windows 7?

Thanks,
Alan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好听的两个字的网名 2024-09-01 05:11:09

我认为清单可能是转移注意力的。我刚刚创建了一个嵌入该清单的控制台应用程序,目标是 .NET 2.0,并且它可以在 XP SP3 上正常运行。

您是否尝试过在未嵌入清单的情况下在 XP 上运行该应用程序?另外,您的目标是哪个版本的 .NET,它是什么类型的 .NET 应用程序(WPF、WinForms、服务等),最后(我必须问)该 XP 计算机上安装的 .NET 版本是否正确?

I think the manifest may be a red herring. I've just created a console application with that manifest embedded, targetting .NET 2.0 and it runs happily on XP SP3.

Have you tried running the app on XP without the manifest embedded? Also, which version of .NET are you targetting, what type of .NET app is it (WPF, WinForms, service, etc) and finally (I have to ask), is the correct version of .NET installed on that XP machine?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文