Form Region Leak in Visual Studio Tools for Office 2008 (v3) Template
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); }
Comments
Anonymous
August 07, 2008
PingBack from http://blog.a-foton.ru/2008/08/form-region-leak-in-visual-studio-tools-for-office-2008-v3-template/Anonymous
November 19, 2008
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.Anonymous
November 19, 2008
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.Anonymous
January 28, 2009
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.Anonymous
February 17, 2009
Recently, I was helping someone with a Outlook item leak type issue involving a Task FormRegion.