Welcome to Office Zealot Sign in | Join | Help

Tip for COM - .NET Interop developers

I was trying my hands at creating a .NET 2.0 component that can be consumed by a COM application.
One of the errors I got in the process of registering the .NET assembly was
RegAsm : warning RA0000 : No types were registered.

This was baffling!! I had done everything right and spent quite some time figuring out what could have gone wrong... until I had a look at the AssemblyInfo.cs. The ComVisible property for the assembly was set to false!! To access types in a .NET assembly from COM, this property should be set to true. Once I did it, I was able to successfully register the .NET assembly and consume it in my COM component. Be sure to remember this when developing COM - .NET interop applications!!

Published Tuesday, December 27, 2005 8:09 AM by desai

Comments

# re: Tip for COM - .NET Interop developers

Friday, December 30, 2005 6:28 AM by Anonymous
Thank you for your tip. However, when I register my assembly, I can see my object now but not all its methods and attributes, whereas they are public ... Have I missed something ?

# re: Tip for COM - .NET Interop developers

Friday, December 30, 2005 7:24 AM by Anonymous
I used a C++ client to call the .NET component. In C++ file, I added a preprocessor directive

#import "DotNetComponent.tlb"

to import the type library created for my .NET component. Check if you missed this step.

# re: Tip for COM - .NET Interop developers

Monday, February 20, 2006 6:37 AM by Anonymous
Thanks a lot!!! I wished I had read your blog sooner!!! You saved me after a 2 hours of not knowing what else to do!

# re: Tip for COM - .NET Interop developers

Tuesday, February 21, 2006 2:44 PM by Anonymous
Fantastic! You saved me after only 15 minutes of messing around on my own.

# re: Tip for COM - .NET Interop developers

Wednesday, February 22, 2006 6:20 AM by Anonymous
Thanks for this tip. It worked! :))

# re: Tip for COM - .NET Interop developers

Friday, March 10, 2006 3:01 PM by Anonymous
Thanks..... I have problem which is solved in second with your tip....otherwise I do not know how much time it is going to take

# re: Tip for COM - .NET Interop developers

Friday, March 10, 2006 3:15 PM by Anonymous
Hi
It was very Helpful. I think you work for Interop. I am developing application in VC++ calling C# DLL. Do you have some sample code of use for CComPtr.
Thanks in advance for your help.

# re: Tip for COM - .NET Interop developers

Friday, March 31, 2006 9:16 AM by Anonymous
Thanks! I tried every trick I've learned so far but it seems .net can surprise us over and over again.

# re: Tip for COM - .NET Interop developers

Sunday, April 02, 2006 7:53 PM by Anonymous
BTW: There is an additional option that turn on and off the Assembly level ComVisible attribute. If you go to the Project properties and select the Application tab, there is a button labeled "Assembly Information...". If you click this button, a diaglog appears that allows you to basically edit the AssemblyInfo.cs file. Well, maybe not everything, but some of the default things anyway. For example, there is a checkbox labeled "Make assembly COM-Visible". Checking and/or unchecking this checkbox sets the [assembly: ComVisible(?)] property true or false (in replace of the question mark "?"). So, if you want all your stuff to be ComVisible(), then you can check this and on the Build tab check "Register for COM Interop".

# re: Tip for COM - .NET Interop developers

Wednesday, April 19, 2006 4:26 PM by Anonymous
Does the ComVisible attribute requirement essentially mean that none of the classes in the Framework itself are directly accessible from COM? Do I have to write my own wrapper to make them accessible or are some of them marked as ComVisible?

# re: Tip for COM - .NET Interop developers

Tuesday, May 09, 2006 1:28 AM by Anonymous
Thanks

# com to .net assembly dll

Tuesday, May 09, 2006 10:46 AM by Anonymous
i would like to know how to convert a com component to an assembly dll refrence i knew that i moght user ceself registration but i dont know how

# re: Tip for COM - .NET Interop developers

Tuesday, June 06, 2006 3:17 PM by Anonymous
Awesome! I had totally forgotten about the COM-visible. Thanks for being there

# re: Tip for COM - .NET Interop developers

Thursday, June 22, 2006 9:39 AM by Anonymous
thanx for sharing, such a stupid thing ;-)!

andy

# re: Tip for COM - .NET Interop developers

Tuesday, September 05, 2006 8:42 AM by Anonymous

Thanks man. It saved lot of my time.

# re: Tip for COM - .NET Interop developers

Friday, October 20, 2006 12:08 PM by Anonymous
Thanks Buddy, your posting really helped me save lot of time.

# re: Tip for COM - .NET Interop developers

Wednesday, November 22, 2006 5:37 AM by Anonymous
Yeah, a very handy tip i would say :)
Thanks pal.

# re: Tip for COM - .NET Interop developers

Friday, November 30, 2007 4:15 AM by billmiller13

Thanks for the post, this saved me after only 5 minutes of struggling.

I would like to add that for me in VS2005, I was building a class.  Rather than editing the assembly file, I perfromed the following steps:

From Project Properties window, choose the compile tab.  Tick the checkbox for "Register for COM Interop".  Hope this helps.

Anonymous comments are disabled