CoCreateInstance - The COM+ registry database detected a system error

1

In a small test project I have this code:

HRESULT hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_ALL, __uuidof( IXMLDOMDocument ), ( void ** ) & m_pDoc);
if ( hr != S_OK )
{
  throw "MSXML DOM Document could not be created";
}

This compiles and runs without problems. In another project the same code fails with:

hr = 0x80110474 The COM+ registry database detected a system error

Both projects are C++ compiled using Visual Studio 2010. I've been through and compared settings side-by-side between the two projects to try and determine what difference could be causing this issue. So far I can see no reason why the test project runs and the other project fails.

Edit - Full sample code listing:

#include "stdafx.h"
#include <atlbase.h>
#include <atlconv.h>
#include "MsXml.h"
int _tmain(int argc, _TCHAR* argv[])
{
    IXMLDOMDocument* m_pDoc = NULL;
    if(FAILED(CoInitializeEx( 0, COINIT_MULTITHREADED )))
      if(FAILED(CoInitializeEx( 0, COINIT_APARTMENTTHREADED )))
        throw "Could not initialize COM";
    HRESULT hr = CoCreateInstance( CLSID_DOMDocument, NULL, CLSCTX_ALL, __uuidof( IXMLDOMDocument ), ( void ** ) & m_pDoc);
    if ( hr != S_OK )
      throw "MSXML DOM Document could not be created";
    return 0;
}
visual-studio-2010
visual-c++
com
com+
asked on Stack Overflow Jun 2, 2011 by FattyPotatoes • edited Jun 2, 2011 by FattyPotatoes

2 Answers

1

Found a solution, although not ideal it solved the problem. I created a new project and manually imported the settings.

answered on Stack Overflow Jun 2, 2011 by FattyPotatoes
0

I've got the same problem with Turbo Delphi: the same code with CoCreateInstance() works in one project and fails in another one with HR=80110474 (COMADMIN_E_REGDB_SYSTEMERR). It was caused by IDE overriding environment variables which are stored in project settings. So it fails only when being runned under IDE (regardless of debugging state). Cleaning up project settings resolves the problem.

answered on Stack Overflow Mar 23, 2015 by Ivan Polyacov

User contributions licensed under CC BY-SA 3.0