2
votes

I'm trying to develop a COM component in Visual C++ 2010 (Express) and I want to be able to consume it from a Visual C# 2010 (Express) program.

My COM DLL is not yet complete, however I defined the DllRegisterServer and DllUnregisterServer functions and they write a lot of stuff into HKEY_CLASSES_ROOT and subkeys. Among the others, I have the following keys:

HKEY_CLASSES_ROOT\My.Components.1\CLSID
    Default Value: {DB05EA30-0320-4D40-A530-6DEAD03D3850}

HKEY_CLASSES_ROOT\CLSID\{DB05EA30-0320-4D40-A530-6DEAD03D3850}
    Default Value: My Components
    Sub Key: InprocServer32
        Default Value: Absolute path of the .dll
        Threading Mode: Apartment
    Sub Key: ProgID
        Default Value: My.Components.1
    Sub Key: TypeLib
        Default Value: {DB05EA31-0321-4D41-A531-6DEAD03D3851}
    Sub Key: Version
        Default Value: 1.0

HKEY_CLASSES_ROOT\TypeLib\{DB05EA31-0321-4D41-A531-6DEAD03D3851}
    Sub Key: 1.0
        Sub Key: 0
            Sub Key: win32
                Default Value: Absolute path of the .tlb

Microsoft JScript is able to attempt the instantiation of the COM object, although since the factory is incomplete, all that is does is output the error code of DllGetClassObject.

On the other side, Visual C# 2010 (or at least the Add Reference... window) doesn't seem to notice the presence of the registered COM object, which doesn't show up in the list. It's pretty clear to me that those objects are only a subset of the installed COM objects.

At what point a COM object will show up there? What am I missing?

Edit

I'm aware of the Browse tab, but I was under the impression that first-class registered COM objects are supposed to show up without explicitly searching for them, but maybe that's not the case.

1
You could use Process Monitor to trace registry accesses performed by VS when populating the list.sharptooth
Interesting, I may try this out in the future. Thank you for your comment.damix911

1 Answers

3
votes
Sub Key: 1.0

This key's Default value must be assigned before the type library can show up in the COM tab. It must contain a description of the type library. The boilerplate phrase is "Acme Foo Type Library 1.0" where "Acme" is your company name and "Foo" is the server or product name.

Using the Browse tab is otherwise my heavy preference, the COM tab is too slow. You'll find out :)