Reading Outlook Appointment.subject fails

M

Mk23

Hi

In a synchronisation application for Outlook 2003 i have the problem, that
the reading of the Outlook.Appointment.subject property fails. The
application stands still by reading, without Exception or any other
information.

Code:
//Loop all appointments
for (object itemObject = restrictedItems.GetFirst(); itemObject != null;
itemObject = restrictedItems.GetNext())
{
File.AppendAllText(path, Environment.NewLine + "Loop item: " + ++i);
if (itemObject is Outlook.AppointmentItem)
{
File.AppendAllText(path, Environment.NewLine + "Item is appointment
item: " + i);
Outlook.AppointmentItem appointment = itemObject as
Outlook.AppointmentItem;
try
{
File.AppendAllText(path, Environment.NewLine + "Item after cast: " + i);
if (appointment != null)
{
File.AppendAllText(path, Environment.NewLine + "Start reading
Properties: " + i);
string subject = appointment.Subject;
File.AppendAllText(path, Environment.NewLine + "Item Subject read:
" + i + " = " + subject);
Outlook.OlResponseStatus responseStatus =
appointment.ResponseStatus;
File.AppendAllText(path, Environment.NewLine + "Item
Responsestatus read: " + i + "=" + responseStatus);
DateTime start = appointment.Start;
File.AppendAllText(path, Environment.NewLine + "Item Start read: "
+ i + "=" + start);
DateTime end = appointment.End;
File.AppendAllText(path, Environment.NewLine + "Item End read: " +
i + "=" + end);
}
else
{
File.AppendAllText(path, Environment.NewLine + "Item is null: " +
i);
}
}
catch (Exception e)
{
File.AppendAllText(path, Environment.NewLine + "Stacktrace: " + i++ +
" " + e.StackTrace);
}
}
}

The last Output is:
Loop item: 8
Item is appointment item: 8
Item after cast: 8
Start reading Properties: 8

The stop is not allways on the same item, and sometimes it runs without any
fault.

Has someone an idea?

Thanks
 
K

Ken Slovak - [MVP - Outlook]

When you say it stops does it hang, or just terminate normally with no
exceptions?

Is this against a PST file or an Exchange mailbox? If a mailbox you might be
running into the normal limit of RPC connections. I'm not sure why that
would occur at different points in the data set if the code is running
against the same folder though.

See if releasing your objects explicitly with Marshal.ReleaseComObject() for
each one helps, followed by a call to GC.Collect() and maybe a wait on
pending finalizers. It slows things down a lot but it ensures actual release
of unmanaged objects that night be holding RPC channels open.

I'd also see if moving the GetFirst() call to before the loop and using a do
loop with GetNext() at the bottom, and using more try{}...catch{} blocks
gives any additional clues as to what's going on.
 
M

Mk23

Hi

Thanks for your answer.

The application hang.
It is against a PST file.

I tried to do the loop with a while and GetFirst() - GetNext(), like you
have suggest. I also sourround every access with try catch.
-> But with the same result and no further information.
The rest with the GC and the ReleaseComObject i will check soon.

regards
 
K

Ken Slovak - [MVP - Outlook]

If it hangs where does it hang? Can you run in debug mode and stop execution
when you stop processing and see where you are and what state things are in
at that point?
 
M

Mk23

Hi I post here our result's. Perhaps it helps someone.

We start a call at microsoft, and tried to find the error. We generate
multiple dumps, but couldn't find any specific reason. We had hints, that the
error happens by at deadlock from an other thread. But we couldn't find out
the guilty thread.

At the end on the machine we could reproduce the error, was installed an
other virus scanner, and since then, the problem doesn't happen again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top