是否可以在部分信任中运行独立的 WPF 应用程序(非 XBAP)?

发布于 2024-08-08 23:23:27 字数 252 浏览 3 评论 0原文

我想,如果我不在窗口中使用除简单图形之外的任何内容,我将能够在部分信任中运行独立的 WPF 应用程序(至少在 Intranet 上)。但不幸的是,即使是最简单的 Hello World 应用程序也无法加载主窗口,并且如果以部分信任的方式运行则会崩溃。

任何人都可以解释为什么会发生这种情况,以及理论上是否可能?

PS最简单的控制台应用程序可以在内联网区域中部分信任地运行,Winforms可以在内联网和互联网中运行(尽管在内联网区域中运行时会显示安全警告)

I thought if I do not use anything beyond simple graphic in a window, I would be able to run a stand-alone WPF application in Partial Trust (at least on Intranet). But unfortunately, even simplest Hello World application fails to load the main window and crashes if run with partial trust.

Anybody can shed some light on why this happens and if it even theoretically possible?

P.S. Simplest console application can run in partial trust in Intranet Zone, and Winforms can run both in Intranet and Internet (though it displays a security warning when running in Intranet Zone)

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

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

发布评论

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

评论(1

夜无邪 2024-08-15 23:23:27

经过更多的尝试后,我发现我的问题是我尝试在调试器下运行我的应用程序。无需调试,简单的 WPF 应用程序就可以在 Internet 和 Intranet 区域中正常运行。

调试时,WPF 应用程序需要区域默认设置的附加权限。这些权限是:

  • 允许在 Intranet 和 Internet 中调用非托管程序集(安全权限)。仍然不确定为什么这与 WinForms 不同以及它在调试模式下需要什么非托管程序集。
  • Internet 区域中的所有窗口和事件(UI 权限)。

如果设置了这两个权限,则可以在部分信任中调试 WPF 应用程序。只是不要忘记在编译版本时重置权限!

After playing with it some more, I found my problem was that I tried my app to run under debugger. Without debugging, simple WPF app can run fine in both internet and intranet zones.

When debugging, WPF application requires additional permissions to zone's default set. These permissions are:

  • Allow calls to unmanaged assemblies (Security permission) in both Intranet and Internet. Still not sure why this is different from WinForms and what unmanaged assembly it needs in debug mode.
  • All windows and events (UI permission) in Internet zone.

If these two permissions are set, you can debug your WPF application in Partial Trust. Just do not forget to reset the permissions when compiling a release!

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