I need to use a ActiveX control in my silverlight application. After some research i found out a few ways in which a silverlight app can use ActiveX control
Use ActiveX control in a webpage along with silverlight plugin and use javascript for interaction between silverlight and activex.
Use a webbrowser control in silverlight 4 and load the webpage containing activex in webbrowser control.
Is there any other way that can utilized to embed activex control in silverlight app. I read somewhere that silverlight 4 has support for COM components. Can silverlight4 provide support for embedding activex control in a silverlight app.
Any help on this is highly appreciated and if some samples/documentation link is there that would be great.
Thanks in advance.
Silverlight does have support for COM automation servers like those used with Microsoft Office. It doesn't have general support for COM though and even if it did, ActiveX controls have very specific hosting requirements.
The idea of using the browser control is a possibility, but it will introduce some significant limitations. For one, you cant use the WebBrowser control in Silverlight unless you're running in out-of-browser mode which means your users would have to take steps to install the Silverlight application.
Additionally, the WebBrowser control (including any ActiveX controls it contains) will always render above your Silverlight content and won't be able to participate in transforms, animations, styling, etc. In other words it will stick out like a sore thumb.
What kind of control is it? Perhaps there is an alternative?
Related
I want to integrate two existing applications into one. One of those apps is built on Windows Forms and the other on WPF.
Is it possible to achieve this?
WPF supplies the WindowsFormsHost class that allows you to host WinForms controls inside a WPF window; conversely, WinForms supplies ElementHost that allows you to host WPF controls inside a form.
Unfortunately how well things work out is highly dependent on exactly what you are doing, last time I checked there were more than a few rough edges. For more information, definitely start from this MSDN page.
If you want to have "independent" WPF windows and WinForms forms inside the same application, you will have to make both frameworks "share" some code in your UI thread's message loop. For a primer on how to do that, see here.
There are various classes to help you with this.
For hosting Windows Forms controls in a WPF Window, you can use the WindowsFormsHost class. For hosting WPF Controls in a Windows Forms Window, you can use the ElementHost class.
You can look here for mor information on the subject (windows forms section):
http://msdn.microsoft.com/en-us/library/ms753178.aspx
I have one silverlight application hosted in WPF environment.
i have created one static eventaggregrator class.
which is used between multiple modules hosted using prism.
but for the event which need to be publish from a module developed in WPF and subscribe in the module developed in *silverlight*.
is it possible? if yes then can anybody give me some ref article or solutions?
WPF and Silverlight use different execution environments, so code cannot be shared at runtime.
If you are hosting the Silverlight control inside a WebBrowser control in WPF then you will have to insert a Javascript layer inbetween your Silverlight control and the WPF host.
So you will subscribe in the .NET world, and then use the InvokeScript() method on your WebBrowser control to invoke a Javascript script which can communicate with the Silverlight control (see ScriptableMember).
I'm attempting to host an ActiveX control in a WPF app. After attempting to use existing info on the web and here, I've hit a dead-end.
I need to use an ActiveX control provided to communicate with a UV power meter. They provide an application that registers and uses the control and even includes some useful demo apps. I stripped out the OCX file and put it here if needed. You won't have the power meter to talk to, but the app and demos will still load the ActiveX control successfully.
I created a simple Windows Forms application. I was able to bring the ActiveX control into the toolbar, drop it into my form, and everything is fine. The demo apps they provide do this as well.
However, getting this to work in a WPF environment is another story. The control can't be added to the toolbox and "dragged" into the app.
So far I've tried two techniques:
Technique found here. I am able to add a reference to the control, but then I enter namespace hell. The xmlns:ax namespace it suggests making cannot find the information. Here's my attempt based on what the object viewer tells me: xmlns:ax="clr-namespace:OphirUsbXLib;assembly=Interop.OphirUsbXLib"
Technique found here. This is essentially to create a new project that creates a library based on Windows Forms, which contains the ActiveX control (yikes). I am able to add the Windows Forms Host, but I cannot get access to the ActiveX control within. I can make the control public, but I still cannot call methods etc. This doesn't look like the right solution.
In short, I have an ActiveX control that works beautifully in Forms, but is a real bitch to get working in WPF.
Any insight is appreciated!
In this situation I would consider making a WinForms usercontrol which wraps the ActiveX control you are trying to use.
You could make public properties and methods which expose each of the required properties and methods on the ActiveX control, and then host this WinForms UC on the in a WPF WinFormsHost control.
I have already done something similar to this, in reverse, hosting a WPF UserControl in a WinForms UserControl, then hosting that on a VB6 Form in a legacy application.
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?
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
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.
I would like to create an ActiveX control that uses Silverlight. Is this possible/sensible and does anyone have an sample code for this?
I am working in a legacy (non web) system that cannot directly use WPF/Silverlight controls. But the system can access ActiveX controls. The thought is that we may be able to host Silverlight in an ActiveX control, and therefore update our rather dated UI.
Read this article.
Silverlight COM Ref.
The article indicates activeX controls in 'agcore.dll' On windows it is actually imported through 'npctrl.dll'.
you compile may have some sort of activex control wizard.
EDIT: With that said. It might be as easy to host IWebBrowser in an activeX control and embedd silvelight into the browser control from local storage via 'xaml'.