Solved

Why would CreateInstance fail?

Posted on 2006-06-18
5
897 Views
Last Modified: 2013-12-03
CreateInstance is being called by Quickbooks QBFC library call IQBSessionManagerPtr(CLSID_QBSessionManager):

sessionManager = new IQBSessionManagerPtr(CLSID_QBSessionManager);

This used to work before I got a new laptop and had to reinstall everything.

I reinstalled QBFC3 (Quickbooks tools that installs the dll and com object),
but don't know what else to try.

0
Comment
Question by:GaryHoff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 16932840
What erros are you getting?
0
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 16941209
have you linked in the library??

Maybe you need to initialise the COM library before trying to instaniate any objects call CoInitialize(NULL)
0
 
LVL 1

Author Comment

by:GaryHoff
ID: 16941797
This code was working before I moved to a new computer.
It links ok, I am using "::CoInitialize(0);" before the call.

HRESULT hr = CreateInstance(clsid, pOuter, dwClsContext);
if (FAILED(hr) && (hr != E_NOINTERFACE)) {
   _com_issue_error(hr);
}

CreateInstance returns 0x80040154, which causes _com_issue_error to be called.
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 16945134
>>CreateInstance returns 0x80040154

That is

//
// MessageId: REGDB_E_CLASSNOTREG
//
// MessageText:
//
//  Class not registered
//
#define REGDB_E_CLASSNOTREG              _HRESULT_TYPEDEF_(0x80040154L)

>>This code was working before I moved to a new computer.

So all you have to do is register the COM DLL that contains 'QBSessionManager' using e.g.

regsvr32.exe  QBSessionManager.dll

Of course you'll have to use the real name of the DLL for this.
0
 
LVL 1

Author Comment

by:GaryHoff
ID: 17039373
I reinstalled a new QB dll, but the code was pointing to the last one - using the GUID from it.
The previous comment, while not the "answer", it still got me to the fix.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question