COM object with CLSID {...} is either not valid or not registered

C

c.verma

I am stuck on one silly thing.It is just about calling unmanaged code
in the C# win/web application. This is what I did:


1) Created a VB dll xyz.dll.
2) Since this is unmanaged dll, I used tlbimp.exe file to create a
managed dll that I am using in my reference of C# project.
tlbimp d:\xyz.dll /out:D:\abc.dll

3) I inculde abc.dll in my C# project and used the following code to
access the methods of this dll.

abc.clsTest myObj = new abc.clsTest();

4) as soon as the above line is hit, I get the following error:

COM object with CLSID {....} is either not valid or not registered

So I registered xyz.dll using regsvr32 utility. But I still get this
error.

I am not able to find any relevant help on this. You have any idea?

I am pretty sure I am missing a very small thing somewhere :-(

Please help me out!
 
B

Bruce Barker

by default vb6 creates new guids on every compile. so after every compile,
you need to re-register and rerun tlbimp.exe your other option is to change
vb6's setting to not do this (don't remember how).

-- bruce (sqlwork.com)
 
I

intrader

I am stuck on one silly thing.It is just about calling unmanaged code
in the C# win/web application. This is what I did:


1) Created a VB dll xyz.dll.
2) Since this is unmanaged dll, I used tlbimp.exe file to create a
managed dll that I am using in my reference of C# project.
tlbimp d:\xyz.dll /out:D:\abc.dll

3) I inculde abc.dll in my C# project and used the following code to
access the methods of this dll.

abc.clsTest myObj = new abc.clsTest();

4) as soon as the above line is hit, I get the following error:

COM object with CLSID {....} is either not valid or not registered

So I registered xyz.dll using regsvr32 utility. But I still get this
error.

I am not able to find any relevant help on this. You have any idea?

I am pretty sure I am missing a very small thing somewhere :-(

Please help me out!
Possible that you have not established an Interop assembly. This happens
fairly automatically when you 'Add Reference' in the IDE and choose a
regeisteres COM object.
 
C

c.verma

Thanks Bruce for your answer. I think I got my answer. There can be two
ways to resolve this problem:
1) Use VS.NET to create the interop wrapper instead of tlbimp.exe. Go
to your project -> rigth click -> Add Reference -> Switch to COM tab ->
If not listed, click browse and select the xyz.dll. This will
automatically generate your interop wrapper which does all the
necessary things to run.

2) If at all you are using tlbimp.exe, make sure that a new guid is not
created everytime you compile the VB dll. For that, Set Binary
Compatibility for xyz.dll. For that: Open your VB project->Project
Properties->Compononent->Select Binary Compatibility.

Also it is always a good idea to unregister the old vb dll, create a
new abc.dll using tlbimp, and then use this abc.dll in VS.NET.
Thanks once again for the answer.
 
E

eligetiv

Hi verma,

i am facing the same problem. Basically i am developing a windows medi
encoder application using the managed dll which i got from online. I
runs fine ony my machine but when i copied the release folder i
different machine then it started giving exception "ClSID {} either no
valid or not registered". I dont have any idea why this is happening.
tried on different machine and it worked fine. So why is this no
working on this machine???

Thanks
vino
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top