Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight and COM Interop

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 Answers

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

like image 107
Red Knight Avatar answered Jun 04 '26 13:06

Red Knight


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.

like image 21
Pavel Minaev Avatar answered Jun 04 '26 12:06

Pavel Minaev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!