<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Wiz/dumb : VSTO</title><link>http://blogs.msdn.com/pcreehan/archive/tags/VSTO/default.aspx</link><description>Tags: VSTO</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Trouble with Live Search Maps Add-in for Outlook</title><link>http://blogs.msdn.com/pcreehan/archive/2008/10/22/trouble-with-live-search-maps-add-in-for-outlook.aspx</link><pubDate>Wed, 22 Oct 2008 16:08:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9011073</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/9011073.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=9011073</wfw:commentRss><description>&lt;p&gt;Several million of you have downloaded the Live Search Maps Add-in for Outlook which allows integration in Outlook with maps and has some cool functionality around extending your appointment blocks to account for automatically calculated travel time among other things.&lt;/p&gt;  &lt;p&gt;We have received a large number of support cases that are caused either directly or indirectly because of this add-in. These include hangs, crashes, and leaks. There could be any number of different reasons for those, but to name one culprit, the add-in interops with CDO 1.21, which if you are a messaging developer following the blogs of anyone on our team, you will know that this is not supported. &lt;/p&gt;  &lt;p&gt;&lt;a title="http://support.microsoft.com/kb/266353" href="http://support.microsoft.com/kb/266353"&gt;http://support.microsoft.com/kb/266353&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Worse than that, it is distributing CDO.dll, which is also not supported. &lt;a href="http://support.microsoft.com/kb/171440"&gt;http://support.microsoft.com/kb/171440&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;A customer of mine reported an issue that lead us to another discovery. The add-in installs a custom form to your Personal forms registry and changes the default form for the calendar to IPM.Appointment.Location. The form it publishes is based on the LEO.oft form that it installs in your Program Files. The OFT was clearly customized from an existing item in the designer’s mailbox. The form contains a value for PR_START_DATE and PR_END_DATE set to 4/6/2006. The problem with this is that Outlook doesn’t use PR_START_DATE and PR_END_DATE, but CDO 1.21 does and OWA will set them as well. Outlook uses custom named props to keep track of dates.&amp;#160; Exchange normally keeps these custom props and PR_START/END_DATE in sync, but only if it needs to because of a modification you did from OWA or something like that. Otherwise, the original values will stick. &lt;/p&gt;  &lt;p&gt;If you have a CDO 1.21 application which filters based on a date, all the appointments you created with this form in your calendar will appear to be on 4/6/2006.&lt;/p&gt;  &lt;p&gt;The long-term plan for what to do about all the problems in this add-in has not been determined at the time of writing of this blog, but it may result in the download being removed from microsoft.com. This won’t help you fix up any items that already exist in your calendar though – nor will it prevent users from using the add-in if they already have it downloaded and installed. &lt;/p&gt;  &lt;p&gt;If you insist on continuing to use the add-in, then please at least use &lt;a title="Updated OFT file in ZIP format" href="http://patrick.creehan.members.winisp.net/Files/LEO.zip"&gt;this updated form&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;You will need to publish this form to your Personal Forms library over the original. If you uncomfortable with that, you can &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Uninstall the add-in using Add/Remove Programs. &lt;/li&gt;    &lt;li&gt;Remove the existing form from your Personal forms library, &lt;/li&gt;    &lt;li&gt;Close Outlook and ensure no instances of Outlook.exe are running in Task Manager. &lt;/li&gt;    &lt;li&gt;Reinstall the add-in, &lt;/li&gt;    &lt;li&gt;Replace the LEO.oft in the Program Files folder (C:\Program Files\Live Search Maps for Outlook) with the one contained in the ZIP file linked above. &lt;/li&gt;    &lt;li&gt;Open Outlook. (the add-in will publish your new form). &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;This should allow your CDO 1.21 code to execute normally on any newly created items. For existing items, you can use Outlook Object Model or CDO 1.21 (or Extended MAPI) code to loop through the appointments in your calendar and delete the PR_START_DATE and PR_END_DATE properties if they are on 4/6/2006 with a message class of IPM.Appointment.Location. Outlook should still be able to work with the appointment just fine without those properties.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9011073" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook+2007/default.aspx">Outlook 2007</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/CDO+1.21/default.aspx">CDO 1.21</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>Misha Shneerson : COM Interop: Handling events has side effects</title><link>http://blogs.msdn.com/pcreehan/archive/2008/10/22/misha-shneerson-com-interop-handling-events-has-side-effects.aspx</link><pubDate>Wed, 22 Oct 2008 16:04:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9011064</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/9011064.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=9011064</wfw:commentRss><description>&lt;p&gt; Misha, a Senior Dev on the VSTO team just posted this blog describing why handling events in managed code can be problematic. This is not news to our team, but he provides a good explanation of why it’s problematic. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/mshneer/archive/2008/10/18/com-interop-handling-events-has-side-effects.aspx"&gt;Misha Shneerson : COM Interop: Handling events has side effects&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If any of what he says sounds familiar, it’s because our own &lt;a href="http://blogs.msdn.com/mstehle"&gt;Matt Stehle&lt;/a&gt; has been talking about this &lt;a href="http://blogs.msdn.com/mstehle/archive/2008/06/12/oom-net-part-5-event-planning.aspx"&gt;for a while&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9011064" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook+Object+Model/default.aspx">Outlook Object Model</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook+2007/default.aspx">Outlook 2007</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>Form Region Leak in Visual Studio Tools for Office 2008 (v3) Template</title><link>http://blogs.msdn.com/pcreehan/archive/2008/08/07/form-region-leak-in-visual-studio-tools-for-office-2008-v3-template.aspx</link><pubDate>Fri, 08 Aug 2008 00:03:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8841695</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/8841695.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=8841695</wfw:commentRss><description>&lt;p&gt;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:&lt;/p&gt;  &lt;p&gt;&amp;quot;The item cannot be saved because it was changed by another user or in a another window.&amp;quot;&lt;/p&gt;  &lt;p&gt;Fortunately, the resolution is easy, you just need to add a call to Marshal.ReleaseComObject to the FormRegionInitializing event in the designer code.&lt;/p&gt; &lt;code&gt;private void FormRegion1Factory_FormRegionInitializing(object sender, Microsoft.Office.Tools.Outlook.FormRegionInitializingEventArgs e)    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Marshal.ReleaseComObject(e.OutlookItem);     &lt;br /&gt;} &lt;/code&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8841695" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook+2007/default.aspx">Outlook 2007</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>Stehle's finally doing his OOM series</title><link>http://blogs.msdn.com/pcreehan/archive/2007/12/07/stehle-s-finally-doing-his-oom-series.aspx</link><pubDate>Fri, 07 Dec 2007 15:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6692649</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/6692649.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=6692649</wfw:commentRss><description>&lt;P&gt;I've been encouraging him to blog his "Matt Stehle's Tenents of OOM Programming" for a while now, and he's finally begun with a series on some common pitfalls we see with developers using OOM in .NET. This &lt;A class="" href="http://blogs.msdn.com/mstehle/archive/2007/12/06/oom-net-part-1-introduction-why-events-stop-firing.aspx" mce_href="http://blogs.msdn.com/mstehle/archive/2007/12/06/oom-net-part-1-introduction-why-events-stop-firing.aspx"&gt;first article&lt;/A&gt;&amp;nbsp;is concerned with a common reason we see for events to stop firing in your VSTO add-ins.&lt;/P&gt;
&lt;P&gt;Rock on Stehle-E-O!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6692649" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook+Object+Model/default.aspx">Outlook Object Model</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>HOWTO: Exposing your VSTO 2005 SE Add-In to External Code</title><link>http://blogs.msdn.com/pcreehan/archive/2006/11/10/howto-exposing-your-vsto-2005-se-add-in-to-external-code.aspx</link><pubDate>Fri, 10 Nov 2006 20:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1054896</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/1054896.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=1054896</wfw:commentRss><description>&lt;P&gt;So with regular COM AddIns in Outlook, to expose your COM Add-In to external applications involved setting the Application.ComAddins.Item("ProgID").Object property equal to an instance of the object. Typically, in your OnConnection event handler, you'd do something like this:&lt;/P&gt;
&lt;P&gt;Application.ComAddins.Item("PROGID").Object = Me&lt;/P&gt;
&lt;P&gt;That allowed external code to get a reference to your COM addin class through its Object property and call public functions on your addin. With VSTO 2005 SE with Outlook 2007, we have a new (better) way of handling this scenario. &lt;/P&gt;
&lt;P&gt;There is a new virtual method which you can override and specify ANY object to be set in that value when the add-in is created.&lt;/P&gt;
&lt;P&gt;You do this by overriding the RequestComAddinAutomationService method in your VSTO add in. See the following MSDN article: &lt;FONT size=2&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/microsoft.office.tools.addin.requestcomaddinautomationservice(VS.80).aspx"&gt;http://msdn2.microsoft.com/en-us/library/microsoft.office.tools.addin.requestcomaddinautomationservice(VS.80).aspx&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;The article on MSDN actually has a good example of what you need to do. Just realize that you do have to include the attributes on your interface class to make them IDispatch and ComVisible.&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1054896" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook+2007/default.aspx">Outlook 2007</category></item><item><title>VSTO add-ins and the NewInspector Event</title><link>http://blogs.msdn.com/pcreehan/archive/2006/07/06/vsto-add-ins-and-the-newinspector-event.aspx</link><pubDate>Fri, 07 Jul 2006 05:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:658520</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>28</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/658520.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=658520</wfw:commentRss><description>&lt;FONT face=Verdana&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/vsto"&gt;VSTO&lt;/A&gt; add-ins for Outlook are great. It's much easier than implementing the IDTExtensibility2 interface. Basically, the way it works is this (actually, &lt;A href="http://blogs.officezealot.com/whitechapel/"&gt;Andrew Whitechapel&lt;/A&gt; does a much better job explaining than I will, so &lt;A href="http://blogs.officezealot.com/whitechapel/archive/2005/07/10/6747.aspx"&gt;here&lt;/A&gt; you go): the AddinLoader.dll keeps a "dormant" list of add-ins that tried to load when the Outlook.exe process is started.&lt;/P&gt;
&lt;P&gt;If there's UI (if there are any Explorers or Inspectors visible), then it fires the _Startup event. If there is no UI (like when using the Outlook View Control or ActiveSync), then it doesn't fire _Startup until the first Inspector or Explorer is made visible. &lt;/FONT&gt;&lt;FONT face=Verdana&gt;Once the last UI element is closed, then VSTO fires the _Shutdown event.&lt;/P&gt;
&lt;P&gt;A typical operation one would usually perform (and a reason for creating an add-in in the first place) is to add some sort of UI to an Inspector or Explorer, such as a button on a command bar or a menu item. In a traditional COM add-in, the way you would do this would be to hook in to the Inspectors.NewInspector event and in the handler for that event, you'd add your UI. And that works great. It works great in VSTO also, except the first time.&lt;/P&gt;
&lt;P&gt;Because VSTO itself is waiting until the NewInspector event fires (in scenarios where Outlook.exe is started with&amp;nbsp;no UI)&amp;nbsp;to fire the _Startup event on your VSTO add-in, it is too late to bind to the event yourself (it's already been fired). So what happens is that the first time an Inspector opens, your button is not added to the CommandBar, but the second time it is!&lt;/P&gt;
&lt;P&gt;The way to get around this problem is simple. Remember that the _Startup event is fired &lt;EM&gt;during &lt;/EM&gt;the NewInspector event. So in your _Startup code, just check the Inspectors.Count property and if it's greater than 0, go ahead and add your button (or whatever)! In subsequent calls to the NewInspector, your code will fire.&lt;/P&gt;
&lt;P&gt;Here's an example:&lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;private Microsoft.Office.Interop.Outlook.Inspectors objInspectors;&lt;BR&gt;&lt;BR&gt;private void ThisApplication_Startup(object sender, System.EventArgs e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;objInspectors = this.Inspectors;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;objInspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(objInspectors_NewInspector);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(objInspectors.Count &amp;gt;= 1)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AddCustomUI();&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;private void ThisApplication_Shutdown(object sender, System.EventArgs e) {&lt;BR&gt;&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;private void objInspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector){&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;AddCustomUI();&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;private void AddCustomUI(){&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//...do your add button thing or whatever here&lt;BR&gt;}&lt;/P&gt;&lt;/CODE&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=658520" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook+Object+Model/default.aspx">Outlook Object Model</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item></channel></rss>