Tuesday, July 24, 2007

warning MSB3214: "*.dll" does not contain any types that can be registered for COM Interop.

Sometimes when a .Net assembly is made COM visible, you might still see MS Visual Studio 2005 complaining

warning MSB3214: "*.dll" does not contain any types that can be registered for COM Interop.

We know we can make a assembly COM visible by

  • adding [assembly: ComVisible(true)] in AsseblyInfo.cs
  • specifying [ComVisible(true)] attribute for the classes that need to be made com visible
  • and also checking the "Register for COM interop" option in project properties window under Build tab

After all these changes you might see Studio still not able to create the TLB for the assebly. In other words not able to register the assebly for COM interop.

Resolution:

I have not found the actual cause of the problem. But following workarounds have fixed the problem

  • Somtimes closing the project and then reloading fixes the problem.
  • Open the command prompt and try registring the component with regasm command. Makre sure you are using the /tlb option. Without it you would get RegAsm : warning RA0000 : No types were registered

The command would look something like

C:\Program Files\Microsoft Visual Studio 8\VC>regasm asseblyname.dll /tlb

If someone knows the actual cause please let me know