3

I am currently trying to reference a .NET COM library in my Visual Basic 6 application. I have registered it, using Regasm and I have set ComVisible to true within my class. However when I try to run my application i get the following error:

ActiveX component can't create object.

My library consists of a very simple function (since I just wanted to test if I could even run it), it just returns the string "Hello World".

I had to use a different machine (machine 1) to create my C# .Net class and then copy that class onto another machine (machine 2) and from there register the dll and reference it in my project. I then tested my project on a separate machine (machine 3) which is were I received the error.

I really need help with this, I have already tried to un-register and re-register it and still to no avail.

3
  • Yes, you did something wrong. We can't see you doing it wrong. Commented Apr 14, 2015 at 19:35
  • @HansPassant I created a C# library on machine 1, and then copied that to machine 2, on machine 2 I registered the dll, which created a .tlb file. I then referenced that .tlb file in my vb6 application. However when I test my project on machine 3 (target machine) I get an error as stated above. Commented Apr 14, 2015 at 19:38
  • @HansPassant, do .tlb files HAVE to be in C:\Windows\system32 folder? Commented Apr 14, 2015 at 19:46

1 Answer 1

1

Try this.

From an elevated command prompt:

  1. RegAsm /codebase /tlb AssemblyName.dll. Take note of the .tlb file generated.
  2. RegTlib File.tlb
  3. Open your VB6 project and reference the .tlb file.
Sign up to request clarification or add additional context in comments.

4 Comments

is there a way to see if the dll actually registered, other than the command prompt saying it successfully registered. The issue with my code now is that it is looking in the wrong file for the dll / .tlb
The command prompt is the best way to determine whether it is registered. To see which .dll it is using, open regedit and search on the ProgID of the COM component (ComponentName.Classname). This will get you a CLSID. Then search that CLSID for the InProcServer32 subkey - this will tell you which file it will access when attempting to load the .DLL and return a COM interface pointer. You can delete these keys and re-register the component if necessary.
For the COM component (ComponentName.ClassName), by ComponentName do you mean the namespace?
Worth noting that RegTlib doesnt exist on windows 2012 now!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.