Solved

Why would CreateInstance fail?

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 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