views:

239

answers:

1

When registering a managed class for COM Interop by hand, certain registry keys are needed. For example

HKEY_CLASSES_ROOT
  CLSID\[My Cls Id]
    InprocServer32
     (Default) = "mscoree.dll"
     Assembly = [My assembly name]
     etc.

I've noticed that when VS registers a library for COM Interop, it also adds a key

HKEY_CLASSES_ROOT
  CLSID\[My Cls Id]
    Implemented Categories
      {62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}

What is this key for, and is it absolutely necessary? As far as I can tell, life goes on just fine without it, but maybe I'm not encountering the circumstances where it is needed.

+2  A: 

It is a CATID, a component category. A control host can use it to, say, filter items that appears in a toolbox, only offering ones that implement an expected set of interfaces. You can see a list of known component categories in the HKCR\Component Categories registry key. The one that Regasm.exe uses means "this COM server is implemented in .NET". Which is kinda useful to know since a .NET program cannot use a COM server that is implemented in a managed language.

CATIDs are not well documented. Which makes them fairly useless, you'll rarely have trouble if you simply omit them. If some control host vendor requires you to use a CATID to make your COM server usable in their host, they'll let you know about that explicitly.

Hans Passant
Hans - helpful answer thanks. Do you mean "a .NET program cannot use a COM server that is implemented in a *un*managed language" rather than "managed language"? More on CATIDs at http://msdn.microsoft.com/en-us/magazine/cc301432.aspx
Simon D
@Simon: no, COM servers are normally implemented in an unmanaged language.
Hans Passant