Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoCreateInstance works great in Release but in debug doesn't

I'm newbie in COM and have a problem in debugging dll. In this code:

        _Check_return_ HRESULT CoCreateInstance(_In_ REFCLSID rclsid, _In_opt_ LPUNKNOWN pUnkOuter = NULL, _In_ DWORD dwClsContext = CLSCTX_ALL)  
throw()  
    {  
        ATLASSERT(p == NULL);  
        return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);  
    }

in return I have error R6034: an application has an attempt to load C runtime library incorrectly.

Plus: In output window of VS 2008 I noticed that debugging stops at certain message:

'OmpClimApp.exe': Loaded '\\omegaserver\omega\app32\OMEGA.DLL\RWUXThemeS.dll', Binary was not built with debug information.

Where is an error?

like image 356
GrinderZ Avatar asked Sep 02 '25 05:09

GrinderZ


1 Answers

Looks like the problem is mixing Debug and Release assembly versions of MS CRT libraries. Microsoft.VC80.CRT and Microsoft.DebugVC80.CRT assemblies use the same common publicKeyToken "1fc8b3b9a1e18e3b" so they cannot be loaded simultaneously into single application.

In your case manifest of RWUXThemeS.dll refers to Microsoft.VC80.CRT but manifest of your application in Debug build refers to Microsoft.DebugVC80.CRT. Trying to load RWUXThemeS.dll causes the error which description actually is not correct, it shall be "Unable to load assembly which public key is already used by another assembly".

Possible solution: you need debug version of RWUXThemeS.dll to be linked to your application in debug build. Assuming its name is RWUXThemeSD.dll.

See MSDN for more details (Community Content, main article doesn't look relevant to your problem).

RWUXTheme library is part of Rogue Wave Stingray Studio, see documentation.

like image 164
Rost Avatar answered Sep 04 '25 18:09

Rost