.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Using ActiveX control in WPF

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :WPF
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 ____. 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 canno

View Complete Post

More Related Resource Links

Activex control to Print a Zebra Tag

Hi All, I'm trying to create an Activex control (similar to the Crystal Activex) to Print tag's from a Client side to a Com Port 1. I created a User control I can pass values to it etc, but It won't Print. Any Ideas? User Control Code:Imports System.Text Namespace Tag Public Interface AxMyControl Property UserText() As String End Interface 'AxMyControl Public Class myControl Inherits System.Windows.Forms.UserControl Implements AxMyControl Private mStr_UserText As String Public Property UserText() As String Implements AxMyControl.UserText Get Return mStr_UserText End Get Set(ByVal Value As String) mStr_UserText = Value TextBox1.Text = mStr_UserText Print() End Set End Property Public Function Print() As Boolean Dim tstr As New StringBuilder ' Printer Code tstr.Insert(0, "^XA") tstr.AppendLine("") tstr.Append("^LH5,30") tstr.AppendLine("") tstr.AppendLine("") tstr.Append("^FO75,110^BY1.5") tstr.AppendLine("") tstr.Append("^B3N,N,75,Y,N") t

ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current

Ok actually i m new to .net so you can tell me that i m right or wrong.   1. First of all i created a class library project in which i added a Windows Form (ModuleTest.cs) in this form i added a web browser control.This form is having on method. public void CheckModule(String username, String password, String modulename, List<CustumFields> objList)         {                  ----------------                  -----------------           }   then i build this whole library.(ClassLibrary.dll). 2. I created a web site in which i added ClassLibrary.dll reference.     then i placed on button control over the page protected void Button1_Click(object sender, EventArgs e)         {             ModuleTest obj = new ModuleTest();             List<CustumFields> objlist= new List<CustumFields>();             obj.CheckModule("admin", "adm1n1@3", "Testing102", objlist);     

ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current

I have created a class library in which i m having Web Forms.now when i use this dll in ASP.NET websiteand call methods            ModuleTest obj = new ModuleTest();            List<CustumFields> objlist= new List<CustumFields>();            obj.CheckModule("admin", "password", "Testing102", objlist);then it gives errorActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartmentthis.components = new System.ComponentModel.Container();            this.panel1 = new System.Windows.Forms.Panel();            this.webBrowser1 = new System.Windows.Forms.WebBrowser();            this.timer1 = new System.Windows.Forms.Timer(this.components);            this.SuspendLayout();this error occurs at this.webBrowser1 = new System.Windows.Forms.WebBrowser();when i mouse over webBrowser1 then it shows null....Whats the problem?

Cannot call an ActiveX control from within a .NET WebBrowser control


I have a simple webpage that starts an ActiveX control. Here's the code:

<script language="JavaScript" type="text/javascript">
   try {
      document.write("<object classid='clsid:1D980DC8-9C45-11D3-9C5C-00A13234F0A2' id='myActiveX' name=' myActiveX'  width='0' height='0'></object>");
      var bReturn = myActiveX.StartControl();
   catch (e) {
      document.write('Failed<br>' + e.name + '<br>' + e.message);

This works well when I call this page directly from Internet Explorer on Windows XP, 7 & server 2003

I created a .NET form in Visual Studio, and added a .NET WebBrowser Control from the toolbox. I set the URL of the WebBrowser to call the same web page.

I complied it & ran the executable. This works well from Windows XP & server 2003, but fails in Windows 7. Here's the JavaScript error message:


ActiveX control replacement by silverlight technology



We developed an ActiveX plug-in for PowerPoint on Windows  The control allows content to be created in some graphical application, transferred to a PowerPoint presentation, and manipulated in 3D in PowerPoint in a view-only manner.  Graphical application is a scientific application which provides ability to create atoms, molecules, defining their bonding and defining surfaces, so user basically create molecules, proteins into the application and transfer it into ActiveX control using  copy-paste.

We want to shift this technology from ActiveX to other, so that it can be used by any software like Microsoft Word, SharePoint, Web browser, and Microsoft Excel.


Can someone tell me alternative of ActiveX? What other technologies can be used to develop same functionality in Microsoft domain? Any pointers indicating for Advantage and disadvantage of using ActiveX and other proposed technology?

I heard about Silverlight, but I do not know anything how it would be useful and how it is beneficial over ActiveX?

How to get Metadata of a ActiveX control on fly in C#?


I am facing problem in getting metadata(like properties,Events and methods) of a ActiveX controls on fly from a web page(using <OBJECT> tag and ActiveXObject or CreateObject), just by giving its ClassID or ProgramID using C# or C++.

Is there any standard way to get meta data of a activex control present in a web page using C# and C++?

Actually i am working for a product based company. The product on which i am working has a feature of Web automation, Currently our product has no capability of automating Activex controls present in a web page. We are enhacing our product to have this support.

i am doing research on this and stucked up at this point of getting meta data of a ActiveX control. I need meta data to know its list of attributes,methods and events, which will help in automating the activex control.

Help me in solving this issue, provide me if any sample code or examples avaialble Or  provide me links to refere.













Accessing window control library .dll from .aspx page (ActiveX)


I have a control in a 'window control library' which handles - 'drag and drop' files from computer to a listbox control, I then reference this .dll in .aspx (See code below). Now, when i try to access this through webserver for drag and drop files i get following errror - The type of the first permission  that failed was : System.Security.Permission.FileIOPermission.

How do I handle this, so that drag and drop of files can happen over the webpage residing at webserver.


namespace testWinControl1
    public partial class UserControl1 : UserControl
        private string appTitle = "DragnDrop Files";
        public UserControl1()
        private void button1_Click(object sender, EventArgs e)

Problem hosting .NET build ActiveX Control in existing VB6 ActiveX control


Hi all,

After struggling several days with this it's time to find some help.

I'm developing for a third party application that supports a modular design by hosting custom ActiveX Controls in an ActiveX Control Container (basically a Tab control with each hosted control on its own tab).
An ActiveX Control build with VB6 with no added code shows up just fine, but I don't want to use VB6, I want to use a .NET UserControl which exposes itself as an ActiveX Control. I successfully created a class library project with a Windows Forms User Control, which is exposed to COM as a control. With some extra registry entries, the control even shows up in the VB6 designer. If I create a small VB6 test application with my .NET control on the form, it shows up just fine.

The problem is that nothing is painted on the tab control, if I add my control to the third party software. The UserControl constructor is called (twice), but that's it. When I switch tabs, the information from the previous tab stays visible, so no Draw() operations are executed at all.

I have read some articles that anything else but Internet Explorer is not supported for hosting ActiveX controls build in .NET but I'm not sure if this is still true.

I hope there is a solution to get this to work in .NET, otherwise I would have to switch to C++ (which

ActiveX Control


Hi ,

 Can any one tell me how to make an  ActiveX control that is installed on the windows and when i double click on any work in the browers (IE,FireFox) then a popup open and Display this word in that popup.  

Please help.


Convert VB6 ActiveX Control to VB.NET And Incorporate it Into ASP.NET

I have an existing ASP.NET application that is written mainly in VB.NET.  Currently one of the ASPX form has an ActiveX control on it.  The ActiveX control is a Windows.Form written in VB6.  Inside that ActiveX control, it has an old third party ActiveX control (Tidestone Formula One) embedded in it.  In other words, we have a Windows-Form VB6 ActiveX wraps around another ActiveX control.

I would like to convert that ActiveX control from VB6 to VB.NET in order to bring everything to the same .NET platform and also to simplify debugging.

I have already converted the VB6 ActiveX control to VB.NET using Upgrade Wizard in Visual Studio 2003.  The problem is that Visual Studio 2003 cannot create Windows.Form ActiveX wrapper.  It can only convert the VB6 ActiveX into a DLL class library (not a control).  I cannot use the converted DLL into the ASPX web form because the DLL is not a control.

I know one of the solution is to replace the old third party ActiveX with .NET version and rewrite the VB6 ActiveX wrapper.  But I am not ready to do this just yet because I am just newly assigned to maintain that application and I need to understand what all my options are.

According to chapter 10 in the Microsoft document "Upgrading Visual Basic 6.0 Applications to Visual Bas

Visual Studio 2005 C# refuses to accept x64 C++ activex control as reference



Firstly: Sorry about my English.


I have many 32bit OCXs, they work fine on x86. But! When I rebuild them on x64, there is an error.

I can not use one of them.

On the developer machine is a Windows xp x64 professional and Visual Studio 2005 sp1.

So, I register the COM control, and after it i can make an instance in ActiveX Test Container (x64) but in VS2005 i can not use this com control. It is not in COM tab page and when i browse the abc.ocx, VS2005 refuses it...

Error message is the next:

A reference to the "...." could not be added.Please make sure that the file is accessible and that it is a valid assembly or COM component.

This contol is a visual control (shows pictures, resize them, ...) and the others are not.

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

Accessing the different controls inside a GridView control

how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

In-Depth look at the GridView Control

In the last article we looked at few of the new controls available in Asp.net 2.0. We also talked about Grid View Control which has replaced the Asp.net 1.1 DataGrid control for good. In this article we will examine more features of the Grid View control. In this article we will see some of the common operations that can be performed using the GridView control. Apart from these operations there are many more functions that can be performed on the control and which we will see in the later articles

ASP.NET repeater control - databind with style

even used the inline editing features, which I at the time thought was the coolest way possible to write ASP.NET code ( I managed to write code to hide all other rows and only show the current one - the row being edited). With a nice looking EditTemplate it looked indeed very slick but it really turned into giant and hard to manage code behind files.

Creating Paging for a Repeater Control

A common question is "How do I implement paging within a Repeater?" Although the beauty of the Repeater control is its flexibility, you're on your own for building most functions. ASP.NET 2.0 has included some new controls that provide paging, as does the DataGrid in ASP.NET 1.1. However, this tip shows you how to roll your own paging for a simple data viewer.

Using TemplateFields in the GridView Control

The GridView is composed of a set of fields that indicate what properties from the DataSource are to be included in the rendered output along with how the data will be displayed. The simplest field type is the BoundField, which displays a data value as text. Other field types display the data using alternate HTML elements. The CheckBoxField, for example, renders as a checkbox whose checked state depends on the value of a specified data field; the ImageField renders an image whose image source is based upon a specified data field. Hyperlinks and buttons whose state depends on an underlying data field value can be rendered using the HyperLinkField and ButtonField field types.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend