WPF 应用程序仅是托管代码吗?

发布于 2024-09-14 03:00:15 字数 81 浏览 3 评论 0 原文

我想在应用程序中使用 WPF。我想用C++写它。是否必须管理应用程序?我知道我可以将托管与非托管混合在一起。我想知道是否可以让整个应用程序不受管理。

I want to use WPF in an app. I want to write it in C++. Does the application have to be managed? I know that I can mix managed with unmanaged. I'm wondering if I can have the whole application be unmanaged.

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

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

发布评论

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

评论(2

飞烟轻若梦 2024-09-21 03:00:15

您可以轻松地使用非托管代码开发 99% 的 WPF 应用程序,但使其 100% 不受托管是相当困难的。

WPF 类没有 Guid 属性,因此它们不能与 COM 一起使用。因此,使用 100% 非托管代码构造 WPF 对象(例如 Button 和 Window)需要非托管 CLR API 之一。 Hosting API 可能是最简单的,但仍然有很多的工作。

如果您愿意接受 99% 的非托管代码,只需使用 /clr 选项编译您的应用程序并使用 IJW 实例化 WPF 对象并调用 Application.LoadComponent 等方法。

另请注意,WPF 绑定到非托管对象要求这些对象完全支持 COM(包括 IDispatch)。

You can easily develop 99% of your WPF application in unmanaged code, but making it 100% unmanaged is quite difficult.

WPF classes don't have a Guid attribute, so they won't work with COM. So constructing WPF objects such as Button and Window with 100% unmanaged code requires one of the unmanaged CLR APIs. The Hosting API is probably the easiest, but it is still quite a bit of work.

If you are willing to accept 99% unmanaged code, just compile your application with the /clr option and use IJW to instantiate WPF objects and call methods like Application.LoadComponent.

Also note that WPF binding to unmanaged objects requires that those objects fully support COM including IDispatch.

淡水深流 2024-09-21 03:00:15

如您所知,您可以通过互操作混合托管和非托管;但是,WPF 运行在 CLR 上。

这是网上的一篇文章,其中一些人推测未来的非托管版本:

http://neilmosafi.blogspot.com/2008/07/unmanagement-version-of-wpf-coming.html

这里是关于 WPF/本机互操作的附加参考,如果您选择去该路线:

http://msdn.microsoft.com/en-us/library /ms742522.aspx

As you already know, you can mix managed and unmanaged via interop; however, WPF runs on the CLR.

Here is an article on the Web where some folks speculate about a future unmanaged version:

http://neilmosafi.blogspot.com/2008/07/unmanaged-version-of-wpf-coming.html

Here is an additional reference on WPF/native interop, should you choose to go that route:

http://msdn.microsoft.com/en-us/library/ms742522.aspx

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