Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not add reference a COM in COM client?

A COM server is create and I registerd that.

When I am trying to add that COM server in a COM Client, I was not able to add, and following error is comming.

" A reference to 'COMTest' could not be added

The ActiveX type Library 'c\user\~\Debug\COMTest.tlb' was exported from a .NET assembly and can not added as a reference.

Add a reference to .NET instead "

can anybody tell me What is the mistake. I register the COM in both way, from VS also and also tried with command prompt.

like image 580
PawanS Avatar asked Jan 06 '11 11:01

PawanS


People also ask

How do I add a COM reference in Visual Studio?

You can also right-click the project node and select Add > Project Reference. If you see a References node in Solution Explorer, you can use the right-click context menu to choose Add Reference. Or, right-click the project node and select Add > Reference.

How do I add a Csproj reference in Visual Studio?

In order to use an external or a 3rd party component in your IDE, you must first add a reference to it. To add a reference in Visual Studio, right click the "references" folder > choose "add reference" and then "Browse" to you DLL.


2 Answers

This is a "why on Earth would you do that" message. Project + Add Reference, Browse tab, select the DLL, not the TLB. So you'll use the .NET class(es) directly instead of going through the COM interop twice.

like image 51
Hans Passant Avatar answered Oct 05 '22 01:10

Hans Passant


I assume you referring .tlb. you should refer .dll,

And after registering it with regsvr32,You just need to find that dll in .net add reference in com tab. Look here for more.

like image 40
indiPy Avatar answered Oct 05 '22 00:10

indiPy