Solved

Why would CreateInstance fail?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

861 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