Silverlight和COM Interop [英] Silverlight and COM Interop

查看:132
本文介绍了Silverlight和COM Interop的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从silverlight与COM控件交互的选项是什么?

What are my options for interacting with a COM control from silverlight?

在我的特定项目中,我有一个旧的ActiveX身份验证控件,我的silverlight应用程序。没有太多无聊的细节,控件需要几个参数,提示用户输入凭据或令牌,并引发事件。我需要从我的控件中设置参数,并以某种方式获取事件的数据给我的控制。

In my particular project, I have a legacy ActiveX authentication control which I would like to leverage in my silverlight application. Without too many boring details, the control takes a couple of parameters, prompts the user for credentials or tokens, and raises events. I need to set the parameters from my control, and somehow get the events' data to my control.

此外,我想让UI看起来像可能。

Furthermore, I would like to get the UI to seem as homogeneous as possible.

这是最好的方法是什么?

What are the best ways of doing this?

推荐答案

IIRC,Silverlight不提供任何方式与COM直接工作 - 没有P / Invoke或COM Interop - 沙盒不允许你在任何情况下这样做。但是,您可以在浏览器中的Silverlight应用程序(这显然将此限制为仅限于IE)中托管ActiveX控件,然后编写一些浏览器中的JavaScript粘合来处理它 - JavaScript可以与ActiveX和Silverlight交互。

IIRC, Silverlight doesn't provide any way work with COM directly - there's no P/Invoke nor COM Interop - and the sandbox wouldn't allow you to do that in any case. However, you could host ActiveX control in the browser alongside your Silverlight application (which obviously restricts this to IE only), and then write some in-browser JavaScript glue to work with it - JavaScript can interact with both ActiveX and Silverlight.

但是我不认为你可以合理地在你的Silverlight应用程序中托管ActiveX控件。最近你可以做的是如上所述,但将ActiveX控件(在浏览器DOM中)放在顶部,如果Silverlight画布在正确的位置,所以它看起来像一个单一的UI。然而,不确定这不会产生任何渲染工件。

I don't think you can reasonably host an ActiveX control inside your Silverlight application, however. The closest you can do is as described above, but position ActiveX control (in browser DOM) on top if Silverlight canvas in the right spot, so it looks like a single UI. Not sure if this will not produce any rendering artifacts, however.

这篇关于Silverlight和COM Interop的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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