Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 906
  • Last Modified:

Why would CreateInstance fail?

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
GaryHoff
Asked:
GaryHoff
  • 2
  • 2
1 Solution
 
Jase-CoderCommented:
What erros are you getting?
0
 
Jase-CoderCommented:
have you linked in the library??

Maybe you need to initialise the COM library before trying to instaniate any objects call CoInitialize(NULL)
0
 
GaryHoffAuthor Commented:
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
 
jkrCommented:
>>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
 
GaryHoffAuthor Commented:
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now