Silverlight and COM Interop

2019-03-21 16:53发布

What are my options for interacting with a COM control from 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.

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

What are the best ways of doing this?

2条回答
smile是对你的礼貌
2楼-- · 2019-03-21 17:04

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.

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.

查看更多
Deceive 欺骗
3楼-- · 2019-03-21 17:28

Silverlight 4 Beta was announced to have COM Interop for Trusted Applications.

More information on the Tim Heuer blog: http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx#com

查看更多
登录 后发表回答