Form Region Leak in Visual Studio Tools for Office 2008 (v3) Template

Published 07 August 08 05:03 PM

I had a case on this a few months ago, but thought more folks might run into this as they start moving to form regions. By default, if you use the VSTO template for creating a form region in Outlook, the item is leaked. This can show up in a number of different symptoms, but the one we saw was that when the item was created (then saved and closed), then modified in WebDav, then they tried to modify the item again in Outlook, the user would get the error:

"The item cannot be saved because it was changed by another user or in a another window."

Fortunately, the resolution is easy, you just need to add a call to Marshal.ReleaseComObject to the FormRegionInitializing event in the designer code.

private void FormRegion1Factory_FormRegionInitializing(object sender, Microsoft.Office.Tools.Outlook.FormRegionInitializingEventArgs e)
{
    Marshal.ReleaseComObject(e.OutlookItem);
}

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# a-foton » Form Region Leak in Visual Studio Tools for Office 2008 (v3) Template said on August 7, 2008 5:14 PM:

PingBack from http://blog.a-foton.ru/2008/08/form-region-leak-in-visual-studio-tools-for-office-2008-v3-template/

# Tobin Harris said on November 19, 2008 9:12 AM:

Hmmm, this is working for me, but it might be because I access the object on FormRegionShowing. I tried releasing it again there, but no cigar.

# Tobin Harris said on November 19, 2008 11:22 AM:

Hmmm, this is working for me, but it might be because I access the object on FormRegionShowing. I tried releasing it again there, but no cigar.

# Patrick Creehan said on January 28, 2009 10:35 AM:

Make sure you are releasing all references to COM objects. If you still can't figure it out, start removing sections of your code until the problem goes away. That might help you narrow down where your leak is. Again, the problem I described above was with no code, just the empty Form Region project.

If you still can't figure out where the leak is, you might want to open a support case with us.

# mstehle: The CDOs and CDONTS of Messaging Development said on February 17, 2009 10:55 AM:

Recently, I was helping someone with a Outlook item leak type issue involving a Task FormRegion. 

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

About Patrick Creehan

Patrick Creehan is an Escalation Engineer in the Office Messaging Development team at Microsoft.
Page view tracker