Hi Ken, thanks for the reply.
The point of the loop is to convert Outlook Contacts objects to My Custom
Contact Objects so it doesn't make sense to declare NewCont outside the loop.
Maybe I'm mis-understanding you?
I've seen similar suggestions in other forum posts and it seems like a cross
your fingers and hope solution which doesn't make me feel very comfortable.
It seems like there should be a reliable way of "closing" objects that you
open. Am I missing something?
Thanks,
Mike D.
"Ken Slovak - [MVP - Outlook]" wrote:
Declare NewCont outside the loop so you aren't creating an instance of it
each pass through the loop. Set both contact objects to null, if that's not
enough to prevent the error then call Marshal.ReleaseComObject() on them. If
that's not enough then call the GC and WaitForPendingFinalizers(). Do it in
steps so you don't add more handling than the minimum needed. Using
ReleaseComObject() and the garbage collection is expensive.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm