NotesSession and AddressBooks (Domino COM Objects)

I am using COM to access Domino objects from Delphi 5 and 6.

Occasionally, when trying to access Session.AddressBooks, I get an

Access Violation exception.

I never get the exception the first time I run my application, which

made me think that it may have something to do with cleaning objects

up.

Below is the piece of code, which will cause the AV:

//////////////////////////////////

ErrCode: HRESULT;

VarSession: OleVariant;

ABArray: OleVariant;

try

ErrCode := CoInitialize( nil );

VarSession := CreateOleObject( ‘Lotus.NotesSession’ );

VarSession.Initialize( ‘Some_Password’ );

AbArray := VarSession.AddressBooks;

//Trying to access AddressBooks in any way here, will sometimes

throw the AV

finally

VarSession := Unassigned;

CoUninitialize;

end;

////////////////////////////////

(I can add a stack trace excerpt for that AV, if anyone is

interested.)

I get the same AV, when I use early binding for the Domino objects and

also managed to get it thrown from a small application in Visual Basic

(by executing the same bits of code).

The way I create and initialise my Session object is the way that

Domino’s help file suggests it should be done.

I made a search through lists of bugs and fixes on the IBM site, but

didn’t find any similar problem reported.

I get this exception so often, though, that I assume that if nobody

else has come accross it so far, it may be due to my misusing of the

Domino objects.

My current Domino/Notes setup includes Domino 5 and Notes 5 and 6 on

the same machine.

Any ideas about what I might be doing wrong are greatly appreciated.