How to use OCX?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Olsen

    #1

    How to use OCX?

    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 .InteropService s.COMException'
    occurred in ActiveGS.NET.ex e

    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.


  • stand__sure

    #2
    Re: How to use OCX?

    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.IHTMLDoc ument2
    htmldoc2 = CType(WebBrowse r1.Document.Dom Document,
    mshtml.IHTMLDoc ument2)

    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?

    Comment

    • Terry Olsen

      #3
      Re: How to use OCX?

      >[color=blue]
      > why do you want to host an Apple ][gs emulator in .NET?
      >[/color]

      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
      "Catastroph ic Failure" with no further explanation. Could be this OCX is
      not compatible? Or maybe I need to use Interop to work with it?


      Comment

      • Dick Grier

        #4
        Re: How to use OCX?

        Hi,
        [color=blue][color=green]
        >>[/color][/color]
        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.


        Comment

        Working...