Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the 'Implemented Categories' key needed when registering a Managed COM Component?

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.

like image 650
Samuel Jack Avatar asked Jan 15 '10 11:01

Samuel Jack


1 Answers

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 should not use a COM server that is implemented in a managed language, it should use the metadata in the assembly directly.

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.

like image 110
Hans Passant Avatar answered Nov 19 '22 20:11

Hans Passant