dcsimg
Results 1 to 7 of 7
  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    6

    COM interop; automation err in VB6 Dev environ

    I have written a vb.net (VS2008) .dll sample. I have built these with the swithes for 'COM Interop'. I move this DLL from my VS2008 machine to my VB6 dev machine; run regasm xxx /tlb; and then write a little sample program to test the DLL. The significant parts of the program program are:


    ------------------------------------------
    << reference is added to the dll>>

    Public M10 As Mar10Class.Mar10Class

    Private Sub cmdMar10Class_Click()

    Set M10 = New Mar10Class.Mar10Class
    M10.HelloMsg ("Mar10 class Msg from VB6 ")

    End Sub

    ---------------------------------------

    If I compile the program, it behaves as expected, but if I try to run it in the dev environment, it gets

    Automation error
    The system cannot find the specified file

    The error happens on line "Set M10 = New Mar10Class....."

    I have thried this with 4 test dlls. The first one I wrote works in both the comile and dev mod. All others only work in compile mode. I moved one of the test projects to another machine that had the VB6 dev environment and on that machine none worked in the dev environ (and all worked when compiled).

    I can't see anything in the .net source code or project properties that would make a diference.

    Can anyone shed some light?

    Much appreciated.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,960

    Re: COM interop; automation err in VB6 Dev environ

    It should help to see your .net code for the dll.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    6

    Re: COM interop; automation err in VB6 Dev environ

    The .net code is:

    <ComClass(Mar10Class.ClassId, Mar10Class.InterfaceId, Mar10Class.EventsId)> _
    Public Class Mar10Class

    #Region "COM GUIDs"
    ' These GUIDs provide the COM identity for this class
    ' and its COM interfaces. If you change them, existing
    ' clients will no longer be able to access the class.
    Public Const ClassId As String = "cca6036a-ef97-4ee0-b6cc-65c5ec1af545"
    Public Const InterfaceId As String = "548857c9-81d9-4d1b-b5e9-f68c98cafe59"
    Public Const EventsId As String = "95744d73-c348-487e-b567-a28306fbb99b"
    #End Region

    ' A creatable COM class must have a Public Sub New()
    ' with no parameters, otherwise, the class will not be
    ' registered in the COM registry and cannot be created
    ' via CreateObject.
    Public Sub New()
    MyBase.New()
    End Sub
    Public Function HelloMsg(ByVal wTest As String) As Boolean
    MsgBox(wTest.ToString, MsgBoxStyle.Information, "Mar10Class hellomsg")
    End Function
    End Class

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,960

    Re: COM interop; automation err in VB6 Dev environ

    Have a look at this for reference in building .Net com-enabled dll.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    6

    Re: COM interop; automation err in VB6 Dev environ

    Okay it seems after a lot of wasted time and many guesses, I managed to get this problem sorted out.

    (The problem was that the vb6 program correctly called the .NET COM dll, but running it from the VB IDE failed).

    These are the steps that worked for me:

    -- put .dll to vb6 dev machine in to dir where the vb6 project is
    -- regasm.exe mydll.dll /tlb (this generates and registers the .tlb file)
    -- add reference to mydll.dll to the vb6 project and code to use the dll.
    -- compile the program and test; assuming no errs, this will work.
    -- however if you try to run this code in the IDE, the error noted above will occur. After searching the Internet, I found mention that the .dll and .tlb needed to be in the VB6.exe directory when running the program from the IDE (the notes I found also indicated that it needed to be registered to this location).
    -- what I found is that indeed the .dll and .tlb needed to be copied to the dir where the VB6.exe was; it did not need to be registered in this dir (but need to be registered in the vb6 prject dir; I'm guessing that registering in the vb6.exe dir with copies also in the vb6 proj dir would also work). The big gotcha is that the whole IDE must be closed and re-opened (not sufficient to close and re-open the project) after the dll files are copied in place. So if you get the automation error; then copy the .dll /.tlb (even register it though not required) into the VB6.exe dir; then try running the project again -- same error; close IDE; re-open IDE; reload the project; run -- no error.

    Hope this helps ....

  6. #6
    New Member
    Join Date
    May 2009
    Posts
    1

    Re: COM interop; automation err in VB6 Dev environ

    KeyNoteSteve, thanks a lot I found your solution and it worked perfectly for me. One other thing that may help is that if your dotnet project needs a .config file, you should also put that in the vb6 directory and name it VB6.EXE.config

  7. #7
    New Member
    Join Date
    Aug 2009
    Posts
    1

    Re: COM interop; automation err in VB6 Dev environ

    Thanks the information above was the solution to developing a app in VB6 that called VS2008 COM dlls. But I am struggling on how to deploy this to a client machine.

    I tried regsvr32.exe the dll and it fails. Registered the tlb using regtlib and it registered fine. When I run the VB6 exe it errors with the ActiveX can't create object.

    Thanks ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.