创建一个 WPF“控件"在外部进程中运行 [英] Create a WPF "control" that is run in an external process

查看:26
本文介绍了创建一个 WPF“控件"在外部进程中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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.

问题是第三方库需要绘制到屏幕上,所以我必须以某种方式在我的 WPF 应用程序的主窗口中使用等效的 HTML iframe.

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.

推荐答案

这是一个艰难的问题,但对你来说幸运的是,最近在这个领域有一些工作要做.

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

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

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.

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

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

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

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!

这篇关于创建一个 WPF“控件"在外部进程中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆