Solved

please help me!

Posted on 2001-08-28
8
299 Views
Last Modified: 2013-11-20
I am working with this mfc/ole stuff that is driving me nuts.

the samples I have work fine, but when I remove the framework they have, and replace it with a console type version, the stuff no longer works...

this is the object I am trying to create:

class IDatabase : public COleDispatchDriver
{
public:
     IDatabase() {}          // Calls COleDispatchDriver default constructor

//continues...

I am trying to create it like this:
IDatabase Database;

then I try to use it:
     Database.CreateDispatch("ACTOLE.DATABASE", pException);              

which I believe calls COleDispatchDriver::CreateDispatch

anyways, I get an exception when I do that...
and I'm not sure why.



please help me
0
Comment
Question by:bebonham
  • 5
  • 2
8 Comments
 
LVL 6

Expert Comment

by:Triskelion
ID: 6432756
What is the ACTOLE.DATABASE?
Does it have to be registered?
Is it a ClassID?

Did you trace through each step of the creation in the debugger?

I made a sample app and it failed at getting the ClassID.

Hmmm...
0
 
LVL 8

Author Comment

by:bebonham
ID: 6432899
okay, it must have been something else...sorry about this...feel stupid..but okay here is where I am now:

#include "StdAfx.h"
#include <iostream>
#include <string>
#include <fstream>
#include "actole.h"
#include "Actflds.h"



void ListContacts()
{
     try
     {
          COleException *pException=new COleException;

     
     IDatabase Database;                                            
     Database.CreateDispatch("ACTOLE.DATABASE", pException);
     Database.Open("C:\\My Documents\\ACT\\Database\\Act5Demo.dbf");
     IContact Contact;
     LPDISPATCH contactDispatch = Database.GetContact();
     //Contact.AttachDispatch(contactDispatch, TRUE);
     Database.Close();
     Database.ReleaseDispatch();
     }

     
     catch(...)
     {
          TRACE("Detected Exception in CActcliDlg::OnListContacts() \n");          
          AfxMessageBox("Detected Exception in CActcliDlg::OnListContacts ");
     }
}




int main()
{
     ListContacts();
     return 0;
}



now, if you uncomment that one line it throws an exception...

yes, the ACTOLE.DATABASE needs to be registered...

how can I get an answer on this...

what do you suggest I do?
I am not too good at the debugger...

0
 
LVL 8

Author Comment

by:bebonham
ID: 6432919
here is what I think I got from the debugger..


Loaded 'C:\WINDOWS\SYSTEM\USER32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\ADVAPI32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\GDI32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\KERNEL32.DLL', no matching symbolic information found.
Loaded symbols for 'C:\WINDOWS\SYSTEM\MSVCRTD.DLL'
Loaded symbols for 'C:\WINDOWS\SYSTEM\MFC42D.DLL'
Loaded 'C:\WINDOWS\SYSTEM\OLE32.DLL', no matching symbolic information found.


Warning: CreateDispatch returning scode = CO_E_NOTINITIALIZED ($800401F0).

Warning: attempt to call Invoke with NULL m_lpDispatch!


what do the experts think?

Thanks,
Bob
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 8

Author Comment

by:bebonham
ID: 6433048
I think my problem is with this:
I am including afxdisp.h

     AfxOleInit();


0
 
LVL 7

Accepted Solution

by:
jimwasson earned 50 total points
ID: 6433731
The error is saying that COM has not been initialized.  I'm uncertain in a console app but you need to call AfxOleInit() before doing any COM calls. I'd do it before calling ListContacts().
0
 
LVL 8

Author Comment

by:bebonham
ID: 6433826
thank you!

you are correct, that is what I also found w/ help from the c++ ta.

problem is I am trying to do a console app :)

I tried the cpp OleInitialize() but that doesn't seem to jive quite right with the MFC stuff.


know any good places to learn about the structure of an MFC program...my problem is I can understand c++ structure enough, but all the different files and stuff that go into MFC are confusing.

Thanks,

Bob
0
 
LVL 7

Expert Comment

by:jimwasson
ID: 6433874
I don't know of any really good places on the net.  MFC has been around for a fair while so there are a ton of books out on it.  I think that the Wrox book Professional MFC by Mike Blaczek (aak -- spelling!) is one of the most comprehensive.  Mike was one of the original architects of MFC.
0
 
LVL 8

Author Comment

by:bebonham
ID: 6433903
yeah I have it...

great paperweight for beginners :)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 50
How to determine file rename from EventLog ? 2 49
zeroFront challenge 7 95
changeXy challenge 13 81
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

813 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

11 Experts available now in Live!

Get 1:1 Help Now