Geeks With Blogs
Path Notes of a Kodefu Master blog

If you're registering your .NET assembly for use in COM, there are a couple of traps that you should be aware of.

You create a class library, make your nifty class you want to instantiate from JavaScript, and compile it. Then you open up the bin folder in Visual Studio Command Prompt:

regasm.exe MyControls.dll

But it doesn't seem to do anything.

""RegAsm : warning RA0000 : No registry script will be produced since there are no
 types to register."

There are three things to check if this happens.

  1. Make sure your library marked ComVisible. Open up AssemblyInfo.cs, and make sure you have [assembly: ComVisible(True)]. If you only want a specific class to be visible, put a [ComVisible(True)] attribute above the class.
  2. Make sure your class is public.
  3. This is the one that seems to catch people off guard. You must have a parameterless constructor for your class. If you have added another constructor, be sure to explicitly declare the parameterless constructor.

After you've checked on those three items, the class should register successfully. Unless you set the ProgId attribute, the class by default will be "Namespace.ClassName."

Unfortunately, this may not be the end of it. If you want to use this within Internet Explorer, particularly if it's a nonvisible control, you may receive a warning about running unsafe ActiveX object. Even after you click the yellow bar at the top and tell it to run, it will fail:

"Automation server can't create object".

Searching around the Internet, I discovered that you need to implement the IObjectSafety interface. But the easiest solution is to give your assembly a strong name.

Posted on Saturday, January 5, 2008 3:29 PM Kodefu | Back to top

Comments on this post: Fun with COM Accessibility

# re: Fun with COM Accessibility
Requesting Gravatar...
thank you your hint with the "parameterless constructor" safe me the day...
Left by Stephan on Jun 03, 2009 10:09 AM

Your comment:
 (will show your gravatar)

Copyright © Chris Eargle | Powered by: