View Single Post
  #8  
Old April 10th 08, 02:53 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default The operation cannot be performed

It may be expensive in time but that's what you have to do. In managed code
there is no way to know when a COM object you dispose of will actually be
garbage collected unless you use GC.Collect() and even sometimes using
WaitForPendingFinalizers() after that.

--
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


"ck" wrote in message
...
Ken,

Yes. This code is posted is just for testing purposes. I am using the UI
to
move the contact item from one folder to another folder. After moving the
contact from one folder to another for few times, the contact will be
'locked'.

Try to open the contact, make some changes on the contact details and save
the contact. I will encounter this message:

- The item cannot be saved because it was changed by another user or in
another window. Do you want to make a copy in the default folder for the
item?

Well, i did follow your advise by removing:

System.Runtime.InteropServices.Marshal.ReleaseComO bject(oContact)

and adding:

oContact = Nothing
GC.Collect()

Then the problem will go away. I think it has to do with the garbage
collection in .Net framework.

By setting oContact = Nothing will not really removed the oContact object
reference. I need to specify GC.Collect() keyword but this is a very
expensive operation. I am wondering if there is any other better method on
releasing resources...


Ads