InteropServices.COMExeption- I need help with debugging

F

Florian Lehner

Hi NG!

I made a small tool for Outlook 2003, which is able to shift certain
appointments. The tool is running without any problems on my machine or other
computers here in the office. Sadly, at the customer's office (they are also
using WinXP Pro, Office 2003) the programm crashes with an "Unknown Error",
claiming:

Systm.Runtime.InteropServices.COMException(0xCA440219): Unknown Error.
at Microsoft.Office.Interop.Outlook._AppointmentItem.Save()
(...)

I have no idea whre to look for the error's cause- maybe you have?
Any suggestsions, anything?

Any help woud be very much appreciated!
 
K

Ken Slovak - [MVP - Outlook]

That's not enough to go on. Show more of the code that precedes the error.
Are you surrounding your attempts to get the appointment with
try{}...catch{} blocks? Are you sure it's really an appointment item?
 
F

Florian Lehner

Well,

Thank you for your answer. I didn't use any exception handling, but I am
gonig to give it a try.
On the other hand, I am quite sure it is an AppointmentItem because I am
only collecting this kind of items.

Here's the code where the error is thrown- maybe there is a major fault that
I've missed:

private void backShift(SummerTPeriod st)
{
Application OlApp = new Application();
NameSpace OlNamespace = OlApp.GetNamespace("MAPI");
MAPIFolder AppointmentFolder =
OlNamespace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);

Items OlItems = (Items)AppointmentFolder.Items;
OlItems.Sort("[Start]", false);
OlItems.IncludeRecurrences = true;
string itemFilter = "[Start] >= " + changeDT(st.FirstDay) + " and [End] <= "
+ changeDT(st.LastDay);

Items StItems = OlItems.Restrict(itemFilter);
StItems.Sort("[Start]", false);
StItems.IncludeRecurrences = true;
AppointmentItem appItem;
appItem = (AppointmentItem)StItems.GetFirst();
while (appItem != null)
{

appItem.Start =
appItem.Start.AddHours((values.ShiftValue) * (-1));

appItem.Save();
appItem = (AppointmentItem)StItems.GetNext();
}
}
 
K

Ken Slovak - [MVP - Outlook]

The only things I see are that you might not be getting all appointments
(some could be meeting items) and that you aren't testing to see if your
restriction is actually returning an Items collection with 0 Count. However,
if you're getting to the point where you're calling save on the appointment
then I have to assume those things aren't the problem here.

With any managed code accesses to COM objects such as Outlook objects you
always should use extensive error handling as well as the casting you're
already doing.

I'd see what comes up if anything when you add error handling, also what
differences there are if any between machines where the code works and where
it doesn't. For example not only deployed requirements and code security but
also what Outlook addins might be running.
 

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