i have a vb6 project that has a reference to a vb.net com library.
the project runs well when i use early binding such as:
Dim b as object
Set b = new myComLib.testObject
when i use late binding such as:
Dim b as object
Set b = CreateObject("myComLib.testObject")
i get the following error:
Run-time error '429': ActiveX component can't create object
Any ideas?
thanks
The registry entries for the .NET COM Interop class in this case are:-
containing a CLSID value and the CLSID entry itself
They are also replicated in
CreateObject uses the HKEY_CLASSES_ROOT entries to retrieve the details of the class name passed in so if they're missing you will receive
Within the VB6 IDE, adding a reference to the dll (in the case of a .NET assembly, via it's tlb file) bypasses this registry search thereby allowing the early binding to work without the COM registry entries.
The class has to be correctly registered for CreateObject to work. This should occur as part of the Visual Studio build process, otherwise it needs to be registered manually using Regasm.
You can test this behaviour by doing the following:-
1) Create a new VB.NET project myComLib registering for COM Interop in the project Compile properties and add a class testObject
2) Build myComLib
3) Create a new VB6 project, add two command buttons to Form1 and the following code
4) Run the VB6 project (without full compile as that will fail)
Command2 will popup a message box, Command1 will fail with
5) Stop the project and add a reference to myComLib via it's tlb file
6) Run the VB6 project and both buttons should now work
7) Go into the registry and delete the HKEY_CLASSES_ROOT\myComLib.testObject entry (this can be re-created by Rebuilding the .NET component, you'll need to close VB6 to carry out the rebuild)
Command2 will now fail with
until the registry entry is re-added.
If you're the
ClassInterfaceType.None
setting, You have to add aProgId
attribute to your class to allow late binding.For example: