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

查看:105
本文介绍了创建一个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.

请看一下外接程序团队的这篇早期文章:

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天全站免登陆