I've got a bunch of C++ COM components that I'm adding to a C# .NET project as references.
All except one can be added successfully.
There is one that is never recognized as a COM.
It doesn't turn up in the COM tab in the Add Reference dialog.
So I forced to load it as a file but I get an error along the lines of:
"Please make sure the file is accessible and that it is a valid assembly or COM component."
The COM in question can be registered successfully using regsvr32 (checked registry to make sure it is there and it is).
However, when I come to add it as a COM reference, it is not recognized as a COM.
I compared this COM to all the other ones that got added successfully and of course there are differences but I can't think which of the differences is causing this one COM to not be recognized.
What am I missing?
Thanks in advance.
I stripped the COM down to its bones but still no luck.
However, investigation has revealed that:
-The GUID of the coclass is written to registry by regsvr32
-None of the GUIDs for the interfaces are written to registry
-However, GUIDs are correctly visible in OLE Viewer
-The registry entry for the coclass GUID is odd in that under InProcServer32 key, there are only the file location and threading model and no mention of InProcServer32
I'm guessing that because the interfaces are not written to the registry, I can't add it to my C# reference as a COM.
Any ideas how this happened?
How can I force regsvr32 to register the interfaces?
DllRegisterServer function wasn't calling
Stupidly simple now that I know what it is, but gosh, it's been a hard week!
Thanks to everyone who made suggestions. They all helped point me in the right direction in the end.
Edited 7-Nov-12 20:46pm
If your object can be registered without problems with regsvr32 then
you should check if your COM dll consist of type library. As it require to make exports automatially. To check it use "OLE-COM Object Viewer" tool (it comes with VS and or SDK). In there select "View TypeLib" and choose your file. If there is no type library then you should to know your objects GUIDs in that DLL and what interfaces they supports; and then you can create managed wrapper but manually. Also usefull tool is "tlbimp.exe" which used to make .NET COM import. NOTE type library can be in separate file usually with same name and "*.tlb" extension - then you should load and import this file.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)