Results 1 to 11 of 11

Thread: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2024
    Posts
    21

    VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    For our modeltrain club I'm writing an XpressNet library, which should later be "included" by the normal application as a DLL.
    The ideal approach seems to me to include the DLL file(s) into a subdirectory under the normal application. By doing so, club members don't have to install the DLL into the registry (since this requires admin privileges, I assume).

    During development I created (see attachment 1-A.zip) a VB Group, called "A-test-that-runs.vbg", which includes two projects: "B_UserInterface.vbp" and "XpressNet.vbp". The first is the normal application, the second holds the code that should later be moved to a DLL. When I start the VB Group, everything runs fine.

    My next step was to create a DLL from the XpressNet code. In the VB6 IDE I selected "XpressNet.vbp" and "File -> Make XpressNet.dll.." Compilation goes without errors, but at the end a window pops-up saying "Error accessing the system registry". I assume this error comes from the fact that I didn't start VB6 with admin privileges. But since I plan to have the generated dll files in a subdirectory under the normal application, I ignored this error message a clicked OK.

    Finally I copied all "B_UserInterface.*" files into a new directory, together with the "DLL" subdirectory. Now that all files are in place, I opened "B_UserInterface.vbp" and in "Project -> References" I browsed till I found the "XpressNet.dll". I included this dll file and the application starts.

    However, as soon as I click in the "start" form "Add XpressNet" I get a "Runtime Error 429 - ActiveX Component Can't Create Object". After clicking Debug, i see the problem is the following line
    Code:
    Public Sub Form_Load()
      Set XpressNet = New XpressNetClass
    I have no clue what goes wrong. Is, what I want, generally impossible? Or is there something in my DLL code that causes the problem? Or is it a minor setting that can easily be fixed?

    PS: I'm developing my VB6 software in Virtual Box running W10.

    Thanks, Aiko
    Attached Files Attached Files

  2. #2
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,196

    Lightbulb Re: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    You absolutely need to register that ActiveX DLL on your development machine so that its TypeLib can be included in the executable and so you can use objects from it early bound. Registration is not needed on client computers if you either include a SxS manifest or load the ActiveX DLL in a "RegFree" way. I have a standalone "cRegFree" class that you can include in your projects for this purpose in this thread: https://www.vbforums.com/showthread....r-ActiveX-DLLs!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2024
    Posts
    21

    Re: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    Quote Originally Posted by VanGoghGaming View Post
    You absolutely need to register that ActiveX DLL on your development machine so that its TypeLib can be included in the executable and so you can use objects from it early bound.
    Thanks.
    I just started VB6 with Admin privileges and created the DLL again. This time no message "Error accessing the system registry" pops-up. Good!
    Subsequently I created the application using the DLL, and everything went fine. So I'm one step further!


    Quote Originally Posted by VanGoghGaming View Post
    Registration is not needed on client computers if you either include a SxS manifest or load the ActiveX DLL in a "RegFree" way. I have a standalone "cRegFree" class that you can include in your projects for this purpose in this thread: https://www.vbforums.com/showthread....r-ActiveX-DLLs!
    Here I have to experiment further tomorrow. Writing DLLs is new for me, and terms like "SxS manifest" and "RegFree" do not yet ring a bell.

    Thanks also for your link, which I will study tomorrow. I do not yet understand what the purpose is of adding code to the application program to access the "Regfree DLL". I assumed that adding the right "Reference" in "Project -> References". But I'll study that tomorrow.

  4. #4
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,196

    Talking Re: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    "RegFree" means that you can use the ActiveX DLL without registering it and adding a reference in "Project -> References". It is of little consequence for personal use but if you mean to distribute your application to others then it becomes invaluable because registration is a source of headaches especially for people running your program without administrator rights as you've just witnessed. Another caveat of registration is that you need to maintain binary compatibility with older versions should you choose to modify your ActiveX DLL and redistribute it (leading to what is called "DLL Hell"). "RegFree" usage doesn't require any of that.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2024
    Posts
    21

    Re: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    Thanks for the further explanation. After reading for several hours, I concluded that RegFree installation is anything but trivial. I did find a lot of information, but I couldn't find a simple tool that would do the trick for me. Therefore I changed my mind, and decided to follow the path of installing the DLL on each of our (6 to 8) machines, using VB6 for that. That seems for me the easier approach.

  6. #6
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,196

    Talking Re: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    It can be a bit daunting at first, especially if you go the "manifest route", that's why I've provided the easy-to-use "cRegFree" class mentioned above.

    Instead of writing:

    Code:
    Set obj = New ClassName ' When the ActiveX DLL is registered
    You write:

    Code:
    Set obj = cRegFree.CreateObj("ClassName", "YourActiveX.dll") ' When the ActiveX DLL is not registered
    That's it. Also you don't need VB6 to register your DLL on your other computers. You can use the "RegSvr32" utility that comes with Windows (in an administrator-mode Command Prompt) window.

  7. #7
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    875

    Re: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    When you compile an ActiveX project(EXE/DLL/OCX), the IDE auto registers it for you. This is why you are getting error accessing the registry. Also, when you start the project within the IDE, VB6 temporarily changes the registry entry pointing to your DLL to "VB6DEBUG.DLL", and routes the calls to the IDE. Once the project ends, VB6 restores the original DLL file. This won't work if you are not running the IDE as Admin.

    Also, not too relevant to AxDLLs, but I will mention it: since ActiveX came in the Windows 9x era, OCX files auto register themselves when they are loaded. This usually happens when you load the form containing them. ActiveX DLL/EXE don't do that, only OCX. So one may have to use an installer, or run the app as Admin once, or use SxS. Here is SxS tutorial:

    https://www.vbforums.com/showthread....SxS-Technology

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jun 2024
    Posts
    21

    Re: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    Indeed I primarily looked at the "manifest route", and read (parts of) the SxS tutorial.

    I'm not sure how to use your "cRegFree" class. It seems to me I first have to download OLEEXP (which I did). After that I downloaded your demo project "ObjectWithEvents.zip (Updated)" and was able to run it.

    But how should I proceed now? Should I just store my dll file and your cRegFree class in the same directory as my application, add the cRegFree class to my application, and change the "Set obj" lines as described by you above? I did this as follows:

    Code:
    Set XpressNet = New XpressNetClass
    Code:
    Set XpressNet = cRegFree.CreateObj("XpressNetClass", "XpressNet.dll")
    But I already get an error message at
    Code:
    Public WithEvents XpressNet As XpressNetClass

  9. #9
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,196

    Lightbulb Re: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    OLEEXP is not needed for the "cRegFree" class which is standalone and can be copied into any project.

    This code requires the ActiveX DLL to be registered on the computer where you develop your project:

    Code:
    Public WithEvents XpressNet As XpressNetClass
    Then you instantiate your objects with:

    Code:
    ' in the same folder:
    Set XpressNet = cRegFree.CreateObj("XpressNetClass", "XpressNet.dll")
    ' or in a subfolder or any other path you want:
    Set XpressNet = cRegFree.CreateObj("XpressNetClass", "Bin\XpressNet.dll")
    Then you compile your project to an executable file which you bundle together with the ActiveX DLL and the resulting app will work on any other computer without needing to register the ActiveX DLL. Hope it's clearer now.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jun 2024
    Posts
    21

    Re: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    I've got it running now. Once I knew how to do it, it is really simple. Thanks for the fantastic help. Really appreciated!!

  11. #11
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,196

    Cool Re: VB6 and DLLs - Runtime Error 429 - ActiveX Component Can't Create Object

    Name:  RockOn.png
Views: 46
Size:  119.8 KB

Posting Permissions

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



Click Here to Expand Forum to Full Width