PDA

View Full Version : Outlook problem



GianMarco
7th October 2009, 17:03
Hi
My software is a thread that every n minutes calls the method for obtaining the outlook appointments. The problem is that the method crashes down.

This is a part of code of the constructor of the thread:

OutlookManager* poiOutMan = new OutlookManager();
This is a part of code of the contrstuctor of class OutlookManager, which reads data from Outlook and contains a field Outlook::Application outlook

if (!outlook.isNull()) {

Outlook::NameSpace session(outlook.Session());
folder = session.GetDefaultFolder(Outlook::olFolderContacts );

}
This is the run of the thread:

void BaseThread::run() {

//while (lock == true) {

poiOutMan -> checkApp();

//}

}
And this is the method checkApp:

void OutlookManager::checkApp() {
some operations with folder




}This code crashes in the checkApp method with this error: ASSERT: "id < 0" in file qaxbase.cpp, line 3710
So I've tried to launch the construction of OutlookManager directly in the run of the thread and to import the checkApp code in the constructor of OutlookManager but it returns a compile error: Starting C:\Documents and Settings\STAGE04\Desktop\Stage Gian\VisionSync\debug\VisionSync.exe...
CoCreateInstance failure (CoInitialize was not called)

QAxBase::setControl: requested control {0006f03a-0000-0000-c000-000000000046} could not be instantiated
Could you please help me? I've tried to find a solution since two days ago but no luck ;(

wysota
18th October 2009, 18:02
You can't access widgets (and other operating system resources) from worker threads. You probably are trying to and thus get occasional crashes.