WPF-App 嵌入来自其他 AppDomain 的 WPF 窗口/控件

发布于 2024-10-12 02:52:05 字数 595 浏览 4 评论 0原文

我有一个生成表单的程序集(它是一个客户端软件)。我可以构建一个应用程序来获取并启动(显示)该表单,没有任何问题。但我无法启动该表单两次,因为该程序集没有提供干净的封装解决方案。每次启动都会崩溃,因为有一些事情不会再次成功初始化。不幸的是,该程序集无法修改。

现在我已将其放入单独的 AppDomain 中,以便能够卸载该程序集。这工作正常,托管应用程序现在可以多次启动该表单。

现在的问题是:我有一个 WPF 应用程序,它不应该显示该程序集的窗体,它应该将其包含在自己的窗口之一中。程序集的 WinForms 窗体已位于 WindowsFormHost 和 WPF-Window(带有 AssemblyAppDomain)中。但我无法将 WPF 窗口指定为主要 WPF 应用程序窗口之一的内容。它位于 AssemblyAppDomain AppDomain 中(并且不与其共享对象空间)。

据我到目前为止的搜索,应该可以在不同 AppDomain 中的两个 WPF 窗口之间建立连接,因为这就是 System.AddIn 的工作方式。应该与PipelineContractFrameworkElementAdapter一起使用。我有点卡住了,任何更具体的提示将不胜感激!

I have an assembly which generates a Form (it is a client-software). I can build an app getting and starting (Show) that form without any problem. But I cannot start that Form twice because the assembly does not provide a clean capsuled solution. Every second start it would crash because several things will not initialize successful a second time. Unfortunately that assembly cannot be modified.

Now I have put that in a seperate AppDomain to be able to unload that assembly. This works fine and the hosting application can now start that Form multiple times.

Now the problem is: I have a WPF-app which should not show that assembly's Form, it should contain it in one of its own windows. The WinForms Form of the assembly is already in a WindowsFormHost and WPF-Window (with AssemblyAppDomain). But I cannot assign the WPF-Window as Content of one of the main WPF-app-windows. It is in the AssemblyAppDomain AppDomain (and object space is not shared with that).

As far as I searched up to now it should be possible to establish a connection between two WPF windows in different AppDomains because that is kind of the way System.AddIn works. Should work with a Pipeline, Contract and FrameworkElementAdapter. I am somewhat stuck and any more specific hints will be appreciated!

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

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

发布评论

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

评论(1

娇俏 2024-10-19 02:52:05

您是否检查过有关 WPF 插件的文档?另请查看此示例

Have you checked the docs about WPF addins? Also check out this example.

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