创建一个 WPF“控件” 在外部进程中运行

发布于 2024-07-27 01:29:26 字数 330 浏览 12 评论 0原文

我有一个 WPF 应用程序,其中包含许多子控件。

其中一个控件托管一个第三方库,该库在幕后运行一些本机代码,这些代码会引发访问冲突并使应用程序崩溃。 不幸的是,删除该库不是一个选择。

我想做的是启动一个新的 Windows 进程,在其中托管第三方库,并以某种方式与其通信。 与 Google Chrome 和 IE8 处理浏览器插件的方式非常相似。

问题是第三方库需要绘制到屏幕上,因此我必须以某种方式在 WPF 应用程序的主窗口中拥有相当于 HTML iframe 的内容。

我不知道如何开始做这件事,到目前为止,谷歌搜索很难。 任何意见是极大的赞赏。

I have a WPF app which contains a number of child controls.

One of these controls hosts a third party library which underneath the covers runs some native code which throws access violations and crashes the application. Unfortunately removing the library is not an option.

What I'd like to do is spin up a new windows process, host the third party library inside that, and somehow communicate with it. Much in the same way that Google Chrome and IE8 handle browser plugins.

The issue is that the third party library needs to draw to the screen, so I have to somehow have the equivalent of an HTML iframe inside my WPF app's main window.

I'm not sure how to get started on this, it's proving difficult to google for thus far. Any advice is greatly appreciated.

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

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

发布评论

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

评论(3

千仐 2024-08-03 01:29:26

这是一项艰巨的任务,但幸运的是,最近在这个领域做了一些工作。

您听说过 .NET 3.5 中的 System.Addin 命名空间吗? 在这种情况下它可能会有所帮助。 它允许将控件加载到单独的 AppDomain 中,但显示在同一 UI 中。 我想你必须做一些工作才能让一切正常通信(以前从未这样做过),但这是可能的。

查看加载项团队的早期帖子:http://blogs.msdn.com/clraddins/archive/2007/08/06/appdomain-isolated-wpf-add-ins-jesse-kaplan.aspx

似乎他们将示例和帮助程序代码保存在 codeplex 上: http://clraddins.codeplex.com/

我对此非常感兴趣,所以如果您成功了,请告诉我们您的情况如何!

This is a tough one, but fortunately for you there is a little work being done in this space lately.

Have you heard of the System.Addin namespace in .NET 3.5? It could probably help in this case. It allows for controls to be loaded in a separate AppDomain, but be displayed in the same UI. I'd imagine you'd have to do a little bit of work to get everything communicating properly (never done this before), but it's possible.

Have a look at this early post from the Add-in team: http://blogs.msdn.com/clraddins/archive/2007/08/06/appdomain-isolated-wpf-add-ins-jesse-kaplan.aspx

Seems like they keep their samples and helper code on codeplex: http://clraddins.codeplex.com/

I'm very interested in this, so if you get this working, let us know how this went for you!

终止放荡 2024-08-03 01:29:26

来得有点晚了。 如果您仍然需要这个,您是否看过这个项目:https://learn.microsoft.com/en-us/archive/blogs/changov/hosting-wpf-ui-cross-thread-and-cross-process

我我正在 LOB 应用程序的多个外部进程中运行多个插件。 我的框架源自上面的项目。

Coming in way late. If you still need this, have you seen this project: https://learn.microsoft.com/en-us/archive/blogs/changov/hosting-wpf-ui-cross-thread-and-cross-process

I'm running multiple plugins in multiple external processes in my LOB app. My framework grew out of the project above.

青衫负雪 2024-08-03 01:29:26

可能不是最简单的任务。 您是否考虑过在单独的应用程序域中托管您的第 3 方内容? 这样,您还将获得良好的隔离级别,同时避免其他项目的麻烦。 它是否必须不断刷新,或者您可以在应用程序中的预定义点刷新吗? 也许有一些方案,您基本上可以对第 3 方输出进行屏幕截图,并将其显示为原始应用程序中的图像......

Probably not the easiest of tasks. Have you considered hosting your 3rd party stuff in a separate App-Domain? That way you will also get a good level of isolation while saving you the hassle of another project. Does it have to be refreshed constantly or could you refresh at predefined points in your application? Maybe some scheme where you basically do a screenshot of the 3rd party output and show it as image in your original app would then be possible...

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