0

i have create a c++ DLL with COM interface with Visual Studio 2013. The DLL get's installed along with registration. In the Ole Object Viewer, i can see typelibrary of this DLL with all exported functions. regsvr32 completes without any error.

Just within C# i can't use, because creation fails with error 0x80040154 - class not found or not registered.

It is not a platform issue. The 64bit version is in system32 and the 32bit version in syswow64 and they are registered there and typelibary information in OLE Object Viewer confirms this.

But the class is not listed in the OLE Object Viewer tree.

Habe noe idea what's missing or wrong.

More over, i have a simliar VC++ project and this COM/DLL can be seen in the view in the OLE Object viewer. It is compiled, linked and installed in exactly the same manner.

I already compared all Compiler, Linker and MIDL settings, checked the .idl file in the projects, the .rgs files... all seems to be the same, except different names and guids.

So it is really strange: One is shown as COM object in the tree of OLE Object viewer and can be used in C# program, the other not.

Please note: There is no compiler error in C# project using this DLL/COM. There is a runtime error on creation 0x80040154.

Summary: i have to COM/DLL, both visual studion projects, deployed in the same manner, the one can be seen in the OLE object tree and can be used in C#, the other not.

Are there any key points i could check and which are required for a successfull listing as OLE COM object ?

PS: The only difference is the MSIL compiler version indicated in the type library view: The good COM/DLL has MSIL 7.xxx the bad one 8.xxx but i don't know where at all to selected MSIL compiler. Both DLL/COM are built by VS2013

2 Answers2

0

OLE/COM Object Viewer shows the registration. When an application attempts to create an instance, there are further steps involved: registration points to server implementation, the library is loaded, class factory is located, class factory is called to created an instance. A failure in these steps results in instantiation failure nevertheless the registration itself is present and valid.

Your typical steps to troubleshoot the problems are:

  1. Setting a break point in constructor of your COM class, in class factory construction, in DllGetClassObject exported function of your DLL, finally in its DllMain - to find out how close the system reaches trying to create an instance. Then step from there to get to the root of the problem.
  2. Using Process Monitor to track registry/file activity around instantiation call and identify issues there (esp. if your DLL with COM server implementation is not even loaded).

If the class is not even listed in OLE/COM Object Viewer, then there is a problem even at registration stage. Your first troubleshooting attempt is to re-register manually and see if you have any registration error, or if it fixes the problem. There is a number of reasons for the registration to fail, a typical is that you have your COM class in your type library, however there is no implementation connected and referenced by OBJECT_ENTRY. With failed registration instantiation is expectedly not working because system cannot pick your implementation up and you see what you see: REGDB_E_CLASSNOTREG error code.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Hello,i checked the manual registration with regsvr32 dll. I started this with admin rights and it completed without an error. The class still is not seen in the object viewer. The typelibrary is listed. – maxchinaski May 13 '15 at 17:50
  • My dll is a CWinApp derived class, so there should be an entry point. When i implement a DllMain, i get an error on compile time. – maxchinaski May 13 '15 at 17:52
  • DllRegisterServer is called on registration but not within my C# project when instantiating the COM object exposed by the typelibrary. In the idl this comobject is defined by coclass mydllCom { [default] interface ImydllCom; }; – maxchinaski May 13 '15 at 17:53
  • `DllRegisterServer` is called when DLL is registered and it should leave registration entries you see in OLE/COM Object Veiwer. `DllGetClassObject` is called on instantiation. As far as I see you have an issue with registration. Instantiation is expectedly failing afterwards. You need to trace/step registration first. – Roman R. May 13 '15 at 19:04
  • Hello, thank you for your answer. Sorry, yes register only once. However, i don't know what to trace, as the registration is not failing. DllRegisterServer returns ZERO, regardless if register manually with regsvr32 or within InnoSetup deployment. I can see the typelibrary in OLE Object Viewer but not listed as COM object. So as registration is not failing how to trace for further errors ? Thank you – maxchinaski May 13 '15 at 21:48
  • Correction: I can see the COM/DLL in the OLE Object View object list. I searched it by name but it is listed by it's crypted CLSID. Compare with the other COM/DLL which works, the typlib information of the problem DLL/COM is missed in the object information tag. As the COM/DLL is integrated by typelib in my C# project, i guess this is the problem – maxchinaski May 13 '15 at 22:42
  • Hello Roman, thank you for the help and the deeper understanding of what happens. Finally said: The server implementation was not found (also not listed in the object in page . – maxchinaski May 13 '15 at 23:29
0

Found the problem: The typelibrary was not associated with object, because the typelibrary CLSID in .rgs file was different from that in .idl file, just by a space which was most likey introduced accidently.

in .rgs file:

TypeLib = s '{7DAA7049 -AAB2-4689-8635-FB6E03423F34}'

in .idl

uuid(7DAA7049-AAB2-4689-8635-FB6E03423F34),

Now i can use the DLL as COM in my C# project. The COM/DLL was not listed in the object tree, because in the .rgs file was no name defined. This is a definition with name and this is the name of the COM/DLL in object viewer; the name follows to s which was previously empty (s'').

ForceRemove {4763F309-D922-227A-A1A8-CDFF29893BBD} = s 'myDllCom Class'