How to use OCX?

T

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
ActiveGS".

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
registered.

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
control?

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

Thanks.
 
S

stand__sure

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,
mshtml.IHTMLDocument2)

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

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

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?
 
D

Dick Grier

Hi,
I tried to create an instance of the OCX via "dim MyOCX as new
ActiveGS".
<<

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).

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net 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
www.mabry.com/vbpgser4 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

Top