My first COM import

I have a .h file with the following declarations:

//////////////////////////////////////////////////////////////////////////////// // Syntek Plug-In Custom Control GUIDs. // //////////////////////////////////////////////////////////////////////////////// // {59DF6360-6F14-4472-82B6-6EAB971EEFAD} DEFINE_GUID(CLSID_IStkCustomControl, 0x59DF6360, 0x6F14, 0x4472, 0x82, 0xB6, 0x6E, 0xAB, 0x97, 0x1E, 0xEF, 0xAD); // {59DF6361-6F14-4472-82B6-6EAB971EEFAD} DEFINE_GUID(CLSID_IStkCustomControl_PropertyPage, 0x59DF6361, 0x6F14, 0x4472, 0x82, 0xB6, 0x6E, 0xAB, 0x97, 0x1E, 0xEF, 0xAD); // Custom Control Interfaces. MIDL_INTERFACE("59DF6360-6F14-4472-82B6-6EAB971EEFAD") IStkCustomControl : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE Get(PKSPROPERTY_STK_CUSTOM_CONTROL_S pStkCustomControl) = 0; virtual HRESULT STDMETHODCALLTYPE Set(PKSPROPERTY_STK_CUSTOM_CONTROL_S pStkCustomControl) = 0; }; 

I would like to port the IStkCustomControl interface in C #. So far I have C # code:

 Guid guid = new Guid(0x59df6360, 0x6f14, 0x4472, 0x82, 0xb6, 0x6e, 0xab, 0x97, 0x1e, 0xef, 0xad); Type type = Type.GetTypeFromCLSID(guid); // line 2 object obj = Activator.CreateInstance(type); 

When executing line 2, I get an exception

Creating an instance of a COM component using CLSID {59DF6360-6F14-4472-82B6-6EAB971EEFAD} from IClassFactory failed due to the following error: 80040202.

What's going on here?

UPDATE: I found out that the IStkCustomControl interface IStkCustomControl implemented in a file called StkProp.ax . I tried to run AxImp.exe StkProp.ax , but it gave me

AxImp Error: Error loading type library / DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))

+4
source share
1 answer

Most often, type information is embedded in the DLL that implements the object. Use OLEView to make sure. If so, then configure the COM link to this DLL and use automatic wrapping.

Having type information as a standalone TLB file is so late in the nineties.

+1
source

All Articles