Solved

Why would CreateInstance fail?

Posted on 2006-06-18
5
868 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
  • 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now