How to use OCX?


Terry Olsen

I have an OCX that I used in VB6 (there is no .NET version of it). There
was an INI file with it. I right-clicked the INI file and chose "Install"
and rebooted. I then created a new VB project and added a reference to the
OCX. I tried to create an instance of the OCX via "dim MyOCX as new

When I run the program I get:

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in ActiveGS.NET.exe

Additional information: COM object with CLSID
{052DF14F-6F28-44A0-9130-294FDA6176EB} is either not valid or not

In VB6, this OCX appears in the toolbox and I can drag it onto the form as
it has a UI. So, in VB.NET, can this appear in the toolbox as a drop-in

Or how could I go about using this OCX in VB.NET?



once the refernce is added you should be able to access it directly
through the RCW. for example, I have a project that references
mshtml.dll. I use it with code like this:

Dim htmldoc2 As mshtml.IHTMLDocument2
htmldoc2 = CType(WebBrowser1.Document.DomDocument,

which is not your exact case, but may point you in the right

why do you want to host an Apple ][gs emulator in .NET?

Terry Olsen

why do you want to host an Apple ][gs emulator in .NET?

Something to do...why not?

Actually, I've hit another snag. I figured out that I needed to register
the file using regsvr32. I got past the original problem and I can
instantiate the object, but when I call any visible method, I get
"Catastrophic Failure" with no further explanation. Could be this OCX is
not compatible? Or maybe I need to use Interop to work with it?

Dick Grier

I tried to create an instance of the OCX via "dim MyOCX as new

After registering the OCX, add it to the ToolBox and drop in on a form.
This creates the wrapper DLL that .NET needs. Then, just use the methods,
properties and events in the same way you would in a VB6 project. Do not
attempt to create it at runtime (as in your code).


Richard Grier (Microsoft Visual Basic MVP)

See for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See to order.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question