<?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>Misha Shneerson : VSTO</title><link>http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx</link><description>Tags: VSTO</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>VSTO 2005 Second Edition - hot off the press</title><link>http://blogs.msdn.com/mshneer/archive/2006/09/14/vsto2005se-announcement.aspx</link><pubDate>Thu, 14 Sep 2006 21:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:754477</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>20</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/754477.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=754477</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5012A573-0D84-4E39-983C-CA22F2107B07&amp;amp;displaylang=en"&gt;VSTO 2005 Second Edition&lt;/A&gt; Beta (aka VSTO2005SE) - this is a new free product that complements VSTO 2005. See this &lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=726538&amp;amp;SiteID=1"&gt;announcement&lt;/A&gt; from KD Hallman if you want to know general details about the product and the roadmap.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I am here to discuss technical details of what it is. First of all - there is a new design time experience for building managed Add-Ins for Office 2003 applications (Excel, Word, Outlook, Visio and PowerPoint - this is for those who use Office 2003 and VS 2005) as well as support for building managed Add-Ins for Office 2007 applications (InfoPath jumped on this band wagon as well).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;There is not much difference between Office 2003 and Office 2007 projects. Here, I can count those differences below:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;Office 2003 projects by default reference Office 2003 PIAs while Office 2007 by default references Office 2007 PIAs&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;Office 2007 projects (except for Visio) do have CustomTaskPanes collection that allows you to easily put WinForm controls onto app level task panes.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;Office 2007 projects (except for Visio and InfoPath) do support easier creation of Ribbon.xml files and hooking those up. So, getting a vanilla Ribbon takes about 30 secs.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;The VSTO2005SE projects are very similar to what the Outlook Add-In project looked in VSTO 2005. The very first difference is that the name of the entry point class has changed - it is not longer ThisApplication, but is rather ThisAdd. So, instead of writing this.Inspectors to get to the Outlook's Inspectors collection you will write this.Application.Inspectors.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;If you want to take advantage of new Office 2007 functionality that is exposed to add-ins you will need to implement a ComVisible&amp;nbsp;public class deriving from&amp;nbsp;any arbitrary interface e.g.&amp;nbsp;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms406046.aspx#office12customizingribbonuifordevelopers_addingdocumentbasedaddins"&gt;&lt;EM&gt;IRibbonExtensibility&lt;/EM&gt;&lt;/A&gt;, &lt;A href="http://msdn2.microsoft.com/en-us/library/ms788695.aspx#outlook2007formregionwalkthrough_addin"&gt;&lt;EM&gt;FormRegionStartup&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;(one does not have to implement &lt;A href="http://msdn2.microsoft.com/en-us/library/ms406050.aspx#office2007createcustomtaskpanes_howcustomtaskpaneswork"&gt;&lt;EM&gt;ICustomTaskPaneConsumer&lt;/EM&gt;&lt;/A&gt;&amp;nbsp;- VSTO runtime takes care when you call &lt;EM&gt;ThisAddin.CustomTaskPanes.Add(new UserControl(), "My task pane")&lt;/EM&gt;. Next you will need to return this class from ThisAddIn's RequestService override. Here is a little example:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;partial&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;ThisAddIn&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;Ribbon1&lt;/SPAN&gt; ribbon;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;protected&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;override&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; RequestService(&lt;SPAN style="COLOR: teal"&gt;Guid&lt;/SPAN&gt; serviceGuid)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (serviceGuid == &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(Office.&lt;SPAN style="COLOR: teal"&gt;IRibbonExtensibility&lt;/SPAN&gt;).GUID)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (ribbon == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ribbon = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;Ribbon1&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; ribbon;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;base&lt;/SPAN&gt;.RequestService(serviceGuid);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR: teal"&gt;ComVisible&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;Ribbon1&lt;/SPAN&gt; : Office.&lt;SPAN style="COLOR: teal"&gt;IRibbonExtensibility&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Unless I missed something that pretty much concludes the general design time discussion. In my next posts I will probably talk more about how to add a Ribbon to VSTO add-ins.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;We will also be shipping a new VSTO runtime redist. Unlike, VSTO 2005 Design Time - the new redist is not a new product, but is rather an upgrade for the original runtime redist. The reason for the runtime upgrade is that it incorporates this addition CustomTaskPanes functionality and support for arbitrary services that VSTO customizations can now expose. Also, we fixed a number of breaking changes in Excel's ListObject functionality that affected the behavior of ListObject's data-binding on Office12.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;One final note - you MOST probably will have trouble using this software if you ever installed VSTO v3 CTP - unfortunately, due to the poor setup support in VSTO v3 CTP, uninstalling it won't solve the problem. You may try to uninstall any the CTP, VSTO 2005 and all the traces of Visual Studio from the machine - then it MIGHT solve the problems. However, the most reliable solution is just re-installing the OS. That is not fun and I am profusely apologizing that you might have to do that. We did much better job with this release to ensure we do have a clear servicing path for this product.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=754477" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/mshneer/archive/tags/Office+12/default.aspx">Office 12</category><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO2005SE/default.aspx">VSTO2005SE</category></item><item><title>Must read for everyone trying to deploy VSTO solutions</title><link>http://blogs.msdn.com/mshneer/archive/2006/01/05/deployment-articles.aspx</link><pubDate>Fri, 06 Jan 2006 09:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:509998</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>16</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/509998.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=509998</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I am breaking the silence to get the word out&amp;nbsp;(to those loyal souls that still aggregate my blog) about 2 articles on VSTO deployment. &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/aa537173(office.11).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa537173(office.11).aspx"&gt;First&lt;/A&gt; article is an in depth overview of VSTO deployment models and proposed solutions. The &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/aa537179(office.11).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa537179(office.11).aspx"&gt;second &lt;/A&gt;one is a complete walkthrough for setup project creation with code samples. Most important&amp;nbsp;- this is a must read for every VSTO developer. If your setup does not install pre-requisites - tons of people won't be able to use your add-in. If your setup does not make sure PIAs are on the machine - tons of people won't be able to use your add-in. If your setup does not deploy CAS policies correctly&amp;nbsp;- tons of people ... &lt;STRONG&gt;But If your setup does deploy CAS policy incorrectly&lt;/STRONG&gt; and allows evil hackers take control over the machine - you are done (if you are not Microsoft, of course:)). The articles address all these points.&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Verdana color=#800080&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Deployment is VSTO's pain point. Part of it is because of the extremely scrutinous security model. Another&amp;nbsp;part is because of our initial desire to support ClickOnce-like capabilities for offline scenarios when ClickOnce was not ready yet to support VSTO-like solutions. The above articles do not remove the pain but help controlling it. In the future we are loooking at removing it at all and making deployment complete part of VSTO experience as it should be - easy and sometimes pleasantly surprising :).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Any development in this area should not go without mentioning some excellent work that has been done by VSTO community. In the past &lt;A href="http://weblogs.asp.net/mnissen/articles/427504.aspx" mce_href="http://weblogs.asp.net/mnissen/articles/427504.aspx"&gt;Mads Nissen&lt;/A&gt; (helped by &lt;A href="http://blog.jausovec.net/index.php?op=ViewArticle&amp;amp;articleId=195&amp;amp;blogId=1" mce_href="http://blog.jausovec.net/index.php?op=ViewArticle&amp;amp;articleId=195&amp;amp;blogId=1"&gt;Peter Jausovec&lt;/A&gt;&amp;nbsp;)&amp;nbsp;posted a solution for VSTO deployment. What Mads has done is very good work&amp;nbsp;even though it suggested to manipulate CAS policies using the CAS APIs (&lt;A href="http://blogs.msdn.com/admin/blogs/blogs.msdn.com/ptorr" mce_href="http://blogs.msdn.com/admin/blogs/blogs.msdn.com/ptorr"&gt;Peter Torr&lt;/A&gt; would not be very happy about this because manipulating security APIs directly is prone to errors. And security bugs may be very costly to both you and your customer).&lt;/P&gt;
&lt;P&gt;Finally I wanted to congratulate my colleagues Lubo, Darryn and McLean for getting this article out.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=509998" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/mshneer/archive/tags/Deployment/default.aspx">Deployment</category></item><item><title>Spaces in SmartTag.Terms collection</title><link>http://blogs.msdn.com/mshneer/archive/2005/10/31/spaces-in-smarttags.aspx</link><pubDate>Mon, 31 Oct 2005 21:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:487379</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/487379.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=487379</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;When you add non-terms into the SmartTag.Terms collection do you expect those terms to be recognized? If you do this is a false expectation. The simplest code to add a SmartTag to a Word document looks like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT color=#0000ff&gt;private void&lt;/FONT&gt; ThisDocument_Startup(&lt;FONT color=#0000ff&gt;object&lt;/FONT&gt; sender, System.&lt;FONT color=#006400&gt;EventArgs&lt;/FONT&gt; e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#006400&gt;SmartTag&lt;/FONT&gt; st = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#006400&gt;SmartTag&lt;/FONT&gt;(&lt;FONT color=#a52a2a&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#a52a2a size=2&gt;http://www.microsoft.sample.com#foo&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT color=#a52a2a&gt;",&lt;/FONT&gt; &lt;FONT color=#a52a2a&gt;"Foo term"&lt;/FONT&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; st.Terms.Add(&lt;FONT color=#a52a2a&gt;"foo"&lt;/FONT&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; st.Terms.Add(&lt;FONT color=#a52a2a&gt;"One Two"&lt;/FONT&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#006400&gt;Action&lt;/FONT&gt; action = new &lt;FONT color=#006400&gt;Action&lt;/FONT&gt;(&lt;FONT color=#a52a2a&gt;"Do nothing"&lt;/FONT&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; st.Actions = new &lt;FONT color=#006400&gt;Action&lt;/FONT&gt;[] { action };&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.VstoSmartTags.Add(st);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;If you run VSTO solution with the code as above and type &lt;EM&gt;foo &lt;/EM&gt;followed by a space you will notice that foo is almost immediatly "tagged". However if you type &lt;EM&gt;One Two&lt;/EM&gt; followed by a space it would not have the same effect. Why is that?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;It is happening because &lt;EM&gt;Terms &lt;/EM&gt;collection should be used only if you need to recognize single tokens. The default implementation of &lt;EM&gt;SmartTag &lt;/EM&gt;will match the members of &lt;EM&gt;Terms &lt;/EM&gt;collections against the &lt;EM&gt;TokenList &lt;/EM&gt;collection as passed into &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/stagsdk/html/stmthRecognize2_HV01082214.asp"&gt;&lt;EM&gt;ISmartTagRecognizer2.Recognize2&lt;/EM&gt; &lt;/A&gt;method.&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT style="BACKGROUND-COLOR: #d3d3d3"&gt;&lt;B class=runinhead&gt;&lt;I&gt;TokenList&lt;/I&gt;&lt;/B&gt;&amp;nbsp;&amp;nbsp;Tokenized representation of &lt;I&gt;Text&lt;/I&gt; parameter. Strings, punctuation, and white space are broken down into actual words for use by the recognizer. This enables streams of tokens to be passed to the recognizer in addition to raw text.&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;&lt;EM&gt;Terms &lt;/EM&gt;collection is not much of use if you want to teach your smart tag a vocabulary of people's names which usually is more than a single word. But you can still use &lt;EM&gt;SmartTag.Expressions&lt;/EM&gt; collection like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; st.Expressions.Add(&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#006400&gt;RegEx&lt;/FONT&gt;(@&lt;FONT color=#a52a2a&gt;"\bOne Two\b"&lt;/FONT&gt;));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana color=#800080&gt;This approach will work pretty well unless you are looking into very large vocabularies. We use pretty&amp;nbsp;dumb sequential algorithm when we just iterate over collection of regular expressions and try to match it against the &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/stagsdk/html/stmthRecognize2_HV01082214.asp"&gt;text that is passed in&lt;/A&gt;. Recognition of smart tags happens on the background thread and the extensive load on the processor will not be horribly noticeable but still the experience would be suboptimal. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I havent given this much thought yet, but it is probably possible to come up with a more effective algorithm. And if you know the characteristics of your vocabulary that is an extra advantage. In this case you can pre-sort you vocabulary, define one single regular expression matching the characteristics of your terms and upon a regex match do quick binary seach to verify that matched text is actually in the sorted array.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Anyone done this or has other ideas?&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=487379" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category></item><item><title>Getting help on VSTO topics</title><link>http://blogs.msdn.com/mshneer/archive/2005/10/06/getting-help.aspx</link><pubDate>Fri, 07 Oct 2005 00:45:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:477997</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/477997.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=477997</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;This post is prompted by a comment left yesterday on my blog. The comment was quite big in size. It went something like this - "my assembly has an ActionsPane and can not be loaded, here is the error message I am getting .... ". This brief introduction was followed by 300 lines of the VSTO error message including the stack at the point of failure + all the assemblies that are loaded in the AppDomain". I removed the comment.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I like to help out, I really do. And the purpose of this blog is to provide information to help our users troubleshoot some of the issues. I do accept requests to talk about mechanics or details of a particular feature. However, if you are stuck please count on the community to get help. I do not really scale very well and can not do much all by myself. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;The preferable way to post your VSTO questions and help requests is to use &lt;A href="http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=16"&gt;VSTO forums&lt;/A&gt;. IMHO the forums format is way better than the newsgroups format. The main feature there is that a thread can be marked as &lt;STRONG&gt;resolved&lt;/STRONG&gt;.&amp;nbsp;This allows us to better manage our resources on open issues and not look through questions that have been already answered. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I should say that before the forums were launched I used to answer question on &lt;A href="http://groups.google.com/group/microsoft.public.vsnet.vstools.office"&gt;Google Groups&lt;/A&gt;. But as soon as I learned about the forums format my monitoring of&amp;nbsp;the newsgroups came to almost complete halt.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Last, but not least. I would like to call upon people to read our forums and answer the questions. As a prize for the contributions you will learn a lot about the technology and might become &lt;A href="http://www.mvps.org/about/"&gt;Microsoft MVP&lt;/A&gt;&amp;nbsp;(those MVPs have access to many more resources than mere mortals).&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=477997" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category></item><item><title>managed addins support in Office 12</title><link>http://blogs.msdn.com/mshneer/archive/2005/09/20/472201.aspx</link><pubDate>Tue, 20 Sep 2005 22:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:472201</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/472201.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=472201</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;At the PDC we have announced support for managed Add-ins across most Office applications. Superficially it is not real news considering today we already have "Shared add-in" project. This project type is there&amp;nbsp;since Visual Studio .NET and this thing is still alive for VS 2005. However, the devil is in the details and when facing the reality of deploying solution generated by such project you would soon learn this is just a beginning of the journey. You will &lt;A href="http://www.shahine.com/omar/ProgrammingForOutlookUsingManagedCodeIsHard.aspx"&gt;run into&lt;/A&gt; incompatibility issues with Office security system, managed code isolation problems, objects lifetime management issues and so on. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;&lt;STRONG&gt;Regasm'ing is not good enough for addins&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;The way shared add-in project works is by throwing at you a skeleton of a class that inherits from IDTExtensibility2 interface. The idea is that all you need to do is implement methods on this interface as you would normally do in VB6. &lt;A href="http://msdn2.microsoft.com/en-us/library/ms166250"&gt;IDTExtensibility2 &lt;/A&gt;interface is the relic of the COM extensibility model and consists of&amp;nbsp;five methods (only 2 of those are usually used - OnConnection and OnDisconnection). When you compile the project VS would write some registry keys and values to &lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;Let the host application know there is a new add-in.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;Allow the host application instantiate your add-in through a call to &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/7295a55b-12c7-4ed0-a7a4-9ecee16afdec.asp"&gt;CoCreateInstance&lt;/A&gt;&amp;nbsp;(which is a standard COM API to instantiate COM objects). Such registration may be also achieved by running &lt;STRONG&gt;regasm myaddin.dll &lt;/STRONG&gt;command and that is why I call the registration process &lt;EM&gt;regasming.&lt;/EM&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;CoCreateInstance receives a parameter (CLSID) which tells it where to look at the registry for the actual DLL that needs to be loaded. Then it loads this DLL into memory and tries to call a native method called DllGetClassObject that must be exposed by the DLL. But guess what - the assembly you justed compiled did not implement the DllGetClassObject and, even if it did, CoCreateInstance looks for the native method - our assembly is completely managed. To workaround the problem regasm actually registers another native DLL which is called mscoree.dll and that is the DLL CoCreateInstance talks to (well, it is a little bit more complicated but let's assume for the sake of this discussion that &lt;STRONG&gt;mscoree.dll&amp;nbsp;IS the CLR&lt;/STRONG&gt;). In turn, mscoree tries to obscure the fact the COM object is managed code and implements the native plumbing that is needed for the code to run. It does this to the best of its ability but there are fundamental differences that just can not be bridged. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;One example of such differences is, of course, the memory management models. In COM a memory resource is immediately released when no one references it. Let's take for example this line of Outlook code - &lt;EM&gt;Application.Inspectors(1).CurrentItem&lt;/EM&gt;. In VB6, After the execution of this line of code completes you are left with only one reference into the Outlook OM - you still reference &lt;EM&gt;Application &lt;/EM&gt;object. In .NET this would result in 3 additional COM objects being reference - one for &lt;EM&gt;Inspectors&lt;/EM&gt; collection, one for the &lt;EM&gt;Inspector&lt;/EM&gt; object and one for the &lt;EM&gt;CurrentItem&lt;/EM&gt;. Those references are kept by implicitly generated managed objects aka as RCWs. Those references are not released as long as the correspondent RCWs are not being collected. In .NET the memory is reclaimed when garbage collector runs which will eventually happen but is hard to predict when. Usually a good way to ensure memory is reclaimed is to unload the AppDomain altogether. (In .NET 1.1 unloading AppDomain would automatically mean running GC, in .NET 2.0 there is a lazy appdomain unloading which does not generally guarantee memory resources are released, but RCWs are special cased and will be releazed before AppDomain fully unloads). However, if your managed assembly was regasmed it will load into default AppDomain which can only be unloaded with the termination of the entire process. And that might create egg-and-the-chicken problem when you do not terminate the process while there are managed references into the object model, but you do not remove the references until the process shuts down.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana color=#800080&gt;Types isolation problem&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Now suppose you have 2 addins in your managed code. Both these add-ins are not placed into GAC and both are not strong named. Each add-in uses a helper library called GoodLibraryForAddins.dll which is shipped by some third party. Except that one of &lt;EM&gt;the&lt;/EM&gt; add-ins uses the v1 version of the library while another one uses the v2 version of the library. The versions are not completely compatible. For example class &lt;EM&gt;GoodLibrary.SmileyFace &lt;/EM&gt;now has additional property &lt;EM&gt;Color. &lt;/EM&gt;When first add-in is loaded into the default AppDomain it will try to use &lt;EM&gt;GoodLibrary.SmileyFace &lt;/EM&gt;class and it will cause the v1 version of the correspondent assembly to be loaded. Next when the second add-in will try to use &lt;EM&gt;GoodLibrary.SmileyFace &lt;/EM&gt;class the CLR will re-use the type information it already knows about and return the class that has been already loaded - the v1 version. Second add-in will then try to use the &lt;EM&gt;Color&lt;/EM&gt; property and will get an unexpected exception.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;&lt;STRONG&gt;Each add-in needs its own AppDomain&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;So, the realization that each Add-in needs its own AppDomain is pretty simple. But that is not what you would get with the "Shared Add-in" project because it uses regasming. The good news are that dedicating an AppDomain on per add-in basis is something you would get if you use VSTO 2005 Outlook Add-in project. The bad news is only Outlook is currently supported. Basically, VSTO 2005 has shipped a native DLL which is called AddinLoader.dll. When CoCreateInstance now tries to create the managed add-in we will essentially create a native add-in implemented by the AddinLoader.dll. The latter will load your managed code, handle the lifetime management issues (e.g. it will unload the AppDomain in OnDisconnection call), and place each managed addin into a separate AppDomain. There is additional plumbing as well, for example the &lt;a href="http://blogs.msdn.com/mshneer/archive/2005/07/22/442866.aspx"&gt;reverse P/Invokes throwing unhandled exception&lt;/A&gt; would not crash the host applications. In addition, there is support for remote deployment and the VSTO security.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;The reason we currently only support Outlook might look lame, but it is the real reason and there is nothing we could do about it. We just did not have enough QA resources to test how the aforementioned AddinLoader will work with applications other than Outlook. And since we did not test it we can not tell you to use it.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Getting this little hiccup cleared out there is another little hiccup left. The one that is generally referred to as "COM Add-ins blacklisting mechanism". Suppose you have several VSTO 2005 Outlook add-ins. Now, one of those horribly crashed during application startup (or was just plainly killed while showing a message box). Office remembers&amp;nbsp;the name of the DLL CoCreateInstance called into and will permanently disable this DLL from running (unless told otherwise from the "Disabled Items ..." dialog). In this case the AddinLoader.dll is getting blacklisted. And this will cause all of the VSTO 2005 Outlook add-ins be disabled. All because of one rotten apple.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana color=#800080&gt;Office 12 knows to do better&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;For Office 12 we have improved the AddinLoader and added support for managed COM add-ins in the &amp;nbsp;following applications: Access, Excel, FrontPage, InfoPath, Project, Outlook, PowerPoint, Publisher, Vision and Word. Office now would be able to natively distinguish between managed add-in and native add-ins. All you need to do is to put some additional registry values to HKCU\Software\Microsoft\Office\&amp;lt;Application&amp;gt;\&amp;lt;AddinName&amp;gt;. The name of the values would be ManifestLocation and ManifestName. ManifestLocation should point to the directory where the VSTO manifest file resides. ManifestName should indicate the name of the manifest file in the directory. Those are exactly same values we are registering today for Outlook add-ins in the HKCR\&amp;lt;YourAddinCLSID&amp;gt; hive. Also note that our tools currently register ManifestLocation and ManifestName in both hives although only the registry values in HKCR are currently used. I should really stress that when you deploy your add-in projects please duplicate those registry values as well to ensure you have good migration story into Office 12.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Office also addresses the blacklisting problem. If a managed add-in&amp;nbsp;causes host application to crash it will be still blacklisted but other managed add-ins will not. This is because the criteria for blacklisting managed add-ins is now the correspondent manifest file, not the entry point DLL (i.e. AddinLoader.dll).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Additional goodies for managed Add-ins will include the regular VSTO stuff. Slightly better programming model, built-in custom task panes support and the advantages of using Visual Studio IDE to write and manage your projects. And might be a lot more.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Happy VSTOing.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=472201" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/mshneer/archive/tags/Office+12/default.aspx">Office 12</category></item><item><title>Back from PDC</title><link>http://blogs.msdn.com/mshneer/archive/2005/09/17/back-from-pdc.aspx</link><pubDate>Sun, 18 Sep 2005 09:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:470802</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/470802.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=470802</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I am back from PDC and I can finally post to my blog! I was not able to do it from LA because 2 weeks before PDC I accidentally ran over my laptop with my van. No surprises here&amp;nbsp;- the laptop&amp;nbsp;is quite useless now. So in LA I had access to computers only at the Convention Center and there I was busy chatting with people that know our VSTO stuff pretty well or do not know anything about it or only used previous v1 version of VSTO and were totally blown away with the v2 demos. &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;I had a chance to talk to the people I heard from before but never met face to face (&lt;A href="http://blog.jausovec.net/"&gt;Peter&lt;/A&gt;, &lt;A href="http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=78470"&gt;Bill&lt;/A&gt;, &lt;A href="http://spaces.msn.com/members/beardieslair"&gt;Darren &lt;/A&gt;and many others, those who have public blogs and those who do not). Many people offered their views and gave us reasons to work on our next version. Should I really say I am grateful for this? Well, I am.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I spoke at the pre-conference where we had about 10 hours long series of sessions covering VSTO v2. I was doing&amp;nbsp;two sessions:&amp;nbsp;one about ActionsPane and SmartTags support and another one about VSTO security. The first session went pretty good. Even the LA power outage that caused us to delay the talk was great because we used it up entirely for the Q&amp;amp;A. The other one was quite difficult. I was told before that CAS related talks are the hardest ones but now I got the chance to experience it myself. I believe I started losing the audience while giving quick overview of CAS - code groups, evidences,&amp;nbsp;four policy levels and intersection of permission sets are just too much to digest in 15-20 minutes of the overview. I completely lost the bravest souls when I pulled up the slide which presented the VSTO AppDomain policy level in the form you usually would see when running &lt;STRONG&gt;caspol -lg &lt;/STRONG&gt;(to get this slide I actually copied code from the caspol into my VSTO assembly and modified it to only list the codegroups for the AppDomain policy level). The rational behind the slide was to show the inner workings of our security policy as opposed to presenting VSTO security as a black box with a set of rules that you have to follow. I believe the talk made good to the sales of Eric's book though and only one guy came up to me and thanked for sharing my views :)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;We announced VSTA at the PDC. There were a lot of questions about how VSTO is related to VSTA. Both technologies are developed by the same team and hence are closely related. Here is the deal. VSTO roughly can be divided into 2 pieces a) a generic runtime and design time support which does not make any assumptions about what host application is and b) integration of this runtime with Word, Excel and Outlook. As a side note, due to this architecture we were able to build our Outlook support in record time - the first prototype of Outlook support was only done in March 2005. VSTA is even more improved version of VSTO's host agnostic part with additional support for&amp;nbsp;managed hosts (VSTO runtime is primarily addressed at native hosts). However, this time instead of doing the integration part ourselves we will offer the ISVs to integrate VSTA into their applications. I should also say that a lot of new concepts were introduced such as contract and more generally MAF - Managed Addins Framework. BTW, for the deep architectural insights of what it takes to design extensible hosts keep an eye on &lt;a href="http://blogs.msdn.com/tq/"&gt;TQ's blog&lt;/A&gt;. Tom is a light version of The Matrix's architect but he actually does make sense :)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I did get an interesting feedback about our blogs. We have a lot of bloggers but we rarely say how we are related organisationally to each other and this sometimes makes things difficult to connect. So here it goes - I do not have any reports and I report to &lt;a href="http://blogs.msdn.com/eric_carter"&gt;Eric Carter&lt;/A&gt;. We primarily&amp;nbsp;are&amp;nbsp;buildng the VSTO runtime and&amp;nbsp;our team is called the frameworks team. Eric reports to &lt;a href="http://blogs.msdn.com/jackg/"&gt;JackG&lt;/A&gt;, TQ is an architect on our team, he is freelancing here and there&amp;nbsp;and also reports to Jack. &lt;A href="http://blogs.officezealot.com/whitechapel"&gt;Andrew Whitechapel&lt;/A&gt; is my and Eric's PM. &lt;a href="http://blogs.msdn.com/pstubbs/"&gt;Paul Stubbs &lt;/A&gt;is a PM working on VSTA. &lt;a href="http://blogs.msdn.com/johnrdurant/"&gt;John Durant&lt;/A&gt; is also a PM driving our Outlook subsidiary. And there is a lot of other great people who not chose yet to go public.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;What else? Ah, feedback. I love feedback. If you made it through the end of this post please add your comments, experiences, requests.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;To sum it up&amp;nbsp;- the conference was great, I am awfully tired, I missed my family and I am happy to see my kids and wife. &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;Happy VSTOing to all of you.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=470802" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/mshneer/archive/tags/PDC05/default.aspx">PDC05</category></item><item><title>VSTO PDC sessions</title><link>http://blogs.msdn.com/mshneer/archive/2005/09/06/461766.aspx</link><pubDate>Wed, 07 Sep 2005 07:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:461766</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/461766.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=461766</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;PDC is just in a week and I will be there. I will present during the preconference with &lt;a href="http://blogs.msdn.com/eric_carter"&gt;Eric Carter&lt;/A&gt; and &lt;A href="http://blogs.officezealot.com/whitechapel/"&gt;Andrew Whitechapel&lt;/A&gt;. The reason three of us are doing this session is because it is 6 hours long! Since we all work directly on the VSTO code base, get ready for deep coverage and bring your toughest questions. One thing I can tell is that the VSTO preconference slide deck is very impressive and it is oriented at developers.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I also previously mentioned that Eric (who happens to be my manager) got me and some other folks to work in Office's building. We were working on integrating our early VSTO 3.0 thinking into Office12 or ... it might be the other way around :) Considering we had only 3 weeks to get something working, while keeping an eye on&amp;nbsp;the last phases of shipping VSTO v2, we did a good job. Many Office sessions in the conference will show the first bits of VSTO vNext.&amp;nbsp;For complete list check out &lt;a href="http://blogs.msdn.com/eric_carter/archive/2005/09/06/461739.aspx"&gt;this compiled&amp;nbsp;guide&lt;/A&gt;. And do not miss the last 2 sessions in this guide.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Also, the rumor is there will be &lt;A href="http://www.amazon.com/exec/obidos/tg/detail/-/0321334884/002-7708739-6697618?v=glance"&gt;new book&lt;/A&gt; signing by Eric.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Have fun, I know I will.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=461766" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/mshneer/archive/tags/PDC05/default.aspx">PDC05</category></item><item><title>Getting plain VSTO ActionsPane to work.</title><link>http://blogs.msdn.com/mshneer/archive/2005/08/16/452059.aspx</link><pubDate>Tue, 16 Aug 2005 10:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:452059</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>16</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/452059.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=452059</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Adding programmable task pane aka ActionsPane with VSTO is a piece of cake. All you really need to do is just add controls to the ActionsPane object using the familiar WinForms paradigm. Here is how you would show a button on the task pane in Word.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Globals.ThisDocument.Controls.Add(new Button());&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;This code produces less than sofisticated task pane but if you remember to do this&amp;nbsp;you are only "this" close to be the ActionsPane&amp;nbsp;expert . If you need to construct something more fancy you do not write any code at all - you use the WinForms designer. Couple clicks to add new UserControl to your project, then couple drag&amp;amp;drops to design the UserControl and set all the right properties in the Property Browser (especially useful is setting the left and right anchors for the text boxes - then those text boxes can resize with the task pane). Then write this code in ThisDocument_Startup event handler:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Globlas.ThisDocument.Controls.Add(new MyUserControl());&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;if you still have not removed the code that adds the empty button then you should see the UserControl stack below the button. This automatic stacking is useful when you want to conditionally add/remove additional UserControls (e.g. you would like to display a currency converter when user fills in expenses part of the trip report - I know the scenario is lame but just bear with me for a moment [:)]).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Additionally your document just became a SmartDocument. It has an XML Expansion Pack (XEP) attached to it. Check out the Tools-&amp;gt;Templates and Add-ins ... dialog. You will see that your document references ActionsPane.xsd schema (which is empty and is there because a schema is required to get whole SmartDocs mechanism get going) and has "Microsoft Actions Pane" XEP as well.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Here is a fun thing to try: delete the "Microsoft Actions Pane" XEP. It is hard to get rid of. It is not the case with other SmartDoc solutions, but this one seems to have an extra protection. Any insights on what is going on here?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;P.S. I am making my posts shorter and aimed to deliver a short point and I am still on the fence whether this is the right thing to do. Is this better than cramming &lt;a href="http://blogs.msdn.com/mshneer/archive/2005/08/10/450069.aspx"&gt;vacations and introductions&lt;/A&gt; into the same post? Or sacrificing the readability and delivering as much information as possible is gonna be more useful when people look for answers later? &lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=452059" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/mshneer/archive/tags/ActionsPane/default.aspx">ActionsPane</category></item><item><title>Back from vacation. ActionsPane, Part 0.</title><link>http://blogs.msdn.com/mshneer/archive/2005/08/10/450069.aspx</link><pubDate>Wed, 10 Aug 2005 22:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:450069</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/450069.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=450069</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I took some time off from work for a family vacation. We spent our relaxation week on Vancouver Island in Canada. Here is &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;more info since already couple of people have asked. The place we stayed at is called &lt;A href="http://www.beachacresresort.com/"&gt;Beach Acres&lt;/A&gt; in Parksville, BC. We &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;rented an ocean view unit with kitchenette and 2 bedrooms. It was just half a minute away from getting to the sand of the &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;beautiful &lt;A href="http://www.comox-valley-realty.com/index.php?content=php.showpic.php%3F&amp;amp;image=DCP_4214.JPG"&gt;Rathtrevor Beach&lt;/A&gt;. The beach is located in the bay which keeps the waters incredibly calm (just like in the pool but &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;with presence of some marine life and without getting allergies from the chlorine). It is very shallow so despite being &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;generally part of the Pacific the water warms up in this place. It also makes for a nice walk during the low-tide. &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;One can wade hundreds of meters into the ocean and dig up the abundant shellfish, catch crabs, build sand castles that are &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;destroyed with the next tide. The kids had fantastic time as well. The only thing that still puzzles me is some irregularity &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;of the tides - one day it would be 2 tides, another day it is 3. It all would happen during different times of the day &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;without any easily understandable cycle. One low-tide could go up to 400 meters away others would be just 200. No &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;recognizable pattern for me whatsoever although reading the local newspapers could help - they do run the tides guide.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;So, it was then and now I am back in my office. Oh, not exactly. &lt;a href="http://blogs.msdn.com/eric_carter"&gt;Eric&lt;/A&gt; made some arrangements for part of our team to go on an &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;offsite and spend some time in building 36 with Office. Nothing super secretive but I can not tell you about it to not spoil &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;anything that might come out of this.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;In other news - in mid-September I am getting out of my Redmond office and going to PDC. Meeting the customers and seeing &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;their side is always fun and gives us inspiration as well. I am looking forward for this especially since Office has so &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;much content to present they even got a separate track in the conference.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Now back to the ActionsPane. The conception of ActionsPane was a perfect example of a customer driven inspiration. &lt;A href="http://blogs.officezealot.com/chris"&gt;Chris Kunicki&lt;/A&gt; was the early adopter of then new SmartDocs technology in Office 2003. SmartDocs umbrella has more than just a &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;programmable task pane but the programmable task pane is the pivotal feature. You could finally plug your own rich UI into Office. Chris was understandably excited and he even &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;contracted to put together samples of SmartDocs that went out as part of Office 2003 Beta programs. He did this only to &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;realize there is something missing to make SmartDocs a success. &lt;BR&gt;Putting together a programmable task pane using SmartDocs technology is not for weak hearted. To name a few difficulties:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;The &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;central piece is an ISmartDocument interface with 25 methods in it most of which need to be implemented to show a single &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;button control. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;The controls in the SmartDocs are stateless. Once the cursor moves from one XML element to another the &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;controls were destroyed and re-created again. So it was up to the developer to maintain the controls state. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;You could have only 1 button click event handler which was called if any &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;of the buttons were clicked. So if you had 5 &lt;FONT face=Verdana color=#800080&gt;buttons you needed to assign every one of those an ID.&amp;nbsp;When button was clicked this ID was passed to the event handler (which is just another method on the interface) and you would go from there. Messy...&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I can go on and on with the list ... And there was no designer whatsoever! So during the early &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;planning days of VSTO Chris sent an e-mail and ask for the designer experience. Then he asked again. And we would reply that &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;it is very hard to put up a designer to support ISmartDocument interface - it took several years to develop WinForms designer &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;we just did not have the resources. But he would ask again.&lt;BR&gt;And then the light bulb went off. We realized we did not need to create the ISmartDocument designer. All we needed is just to &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;find a way to host WinForms inside the task pane. This WinForm would fill the entire pane area and would serve as a container &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;for the components designed by the developers. &lt;BR&gt;Then things started to happen with the speed of light. The first prototype was just positioning a WinForm form on top of the &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;task pane. It had some message routing problems but it did gave people the ability to see the potential behind the concept. &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;The right hosting solution is to host the WinForms natively e.g. the way IE does it - through ActiveX interfaces. Next, &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;Office added the capability to stretch the ActiveX control to fill the task pane area entirely. This was especially &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;incredibly because it happened only 2 months before Office 2003 shipped. Next Brian fixed for us the issues in WinForms that &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;cause some focus management issues - you can see those issues if you use .NET Fx 1.1 to show UserControl in the task pane. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;And it was ready. Chris likes to say &lt;A href="http://blogs.officezealot.com/chris/archive/2005/08/02/7635.aspx"&gt;ActionsPane is his favorite feature&lt;/A&gt; and I could not agree more.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;In my next posts I will talk about creation of vanilla ActionsPane, then using UserControls to design ActionPane components, adding context sensitivity to the ActionsPane using new XMLNode's ContextEnter and ContextLeave events, discuss some usability aspects of the ActionsPane, answer questions (if any)&amp;nbsp;and possibly provide some peek under the hood.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=450069" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/mshneer/archive/tags/ActionsPane/default.aspx">ActionsPane</category></item><item><title>NewsGator and VSTO Outlook support</title><link>http://blogs.msdn.com/mshneer/archive/2005/07/25/443162.aspx</link><pubDate>Tue, 26 Jul 2005 00:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:443162</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/443162.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=443162</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Until &lt;A href="http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=53585"&gt;recently&lt;/A&gt; people had "tough" choice to make - in your Outlook either run NewsGator or Outlook COM Add-ins with VSTO support. Both of these did not work together. This is because NewsGator did not support .NET Fx 2.0 which is required by VSTO.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Now .NET Fx 2.0 is &lt;A href="http://www.newsgator.com/news/archive.aspx?post=62"&gt;supported by NewsGator&lt;/A&gt; and the issue seems to be &lt;a href="http://blogs.msdn.com/acoat/archive/2005/07/25/442841.aspx"&gt;resolved&lt;/A&gt;. But I still wonder whether NewsGator could use VSTO loader in the future? Then they will run in their own AppDomain without stepping on the toes of other managed Outlook COM Add-ins.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Thanks to &lt;a href="http://blogs.msdn.com/acoat/"&gt;Andrew Coates&lt;/A&gt; for keeping an eye on this.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=443162" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category></item><item><title>Closing Documents Programmatically is not simple</title><link>http://blogs.msdn.com/mshneer/archive/2005/07/22/442866.aspx</link><pubDate>Fri, 22 Jul 2005 21:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:442866</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/442866.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=442866</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Both Word and Excel OMs have APIs that allow closing documents programmatically. I suppose there are some scenarios when people would like to call ThisWorkbook.Close() from within their document customizations. This has some interesting effects when such call is made from within managed VSTO customizations.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;First of all closing the document will also cause the current AppDomain be unloaded. This is the basic feature of VSTO loader to ensure managed code does not hold references to the document that has just been closed. Note that AppDomain unloading happens while there is code from this AppDomain on the managed stack. This is kind of an interesting situation but CLR folks have found a way to deal with it. They try to unwind the stack as aggressively as possible to the frame where first method from the unloading AppDomain has been entered. To accomplish that CLR throws &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemthreadingthreadabortexceptionclasstopic.asp"&gt;System.Threading.ThreadAbortException&lt;/A&gt;. In the documentation you will find that when this exception is thrown you can run but you cannot hide: &lt;/FONT&gt;&lt;STRONG&gt;ThreadAbortException&lt;/STRONG&gt; is a special exception that can be caught, but it will automatically be raised again at the end of the &lt;B&gt;catch&lt;/B&gt; block. &lt;FONT face=Verdana color=#800080&gt;Chris Brumme explains the whole process in much more details so you might want to read his excelleny &lt;a href="http://blogs.msdn.com/cbrumme/archive/2003/06/01/51466.aspx"&gt;blog entry&lt;/A&gt;. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;When ThreadAbortException reaches the base-most frame the exception turns into the DomainUnloaded exception and, in our case, the execution transitions into the native code. And now the fun begins. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;First scenario: the document was closed from within an event handler for Excel or Word event such as Worksheet.SelectionChange. In this case CLR realizes the host application calls the managed code as a regular COM call and the failure should be communicated according to COM conventions. The convention is that failure code is returned. In this case it is COR_E_APPDOMAINUNLOADED. Excel/Word ignore the return value&amp;nbsp;and execution continues normally.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Second scenario: the document was closed from within a WinForms event handler. For example a button on a modeless from was pressed and Button.Click event was raised. In this case the point of entry into the managed code is a windows procedure (WndProc) implemented in the depths of System.Windows.Forms assembly - all managed code. Such invocation is called "Reverse P/Invoke" as it is the reverse situation from when managed code calls native API through mechanism known as Platform Invoke. Contrary to the COM scenario CLR does not know about any convention to communicate errors to the native callers. So, it just throws an exception, particularly Windows SEH. There is another long but outstanding&amp;nbsp;&lt;a href="http://blogs.msdn.com/cbrumme/archive/2003/10/01/51524.aspx"&gt;post&lt;/A&gt; on this from Chris Brumme. So, now this SEH is thrown right into Excel/Word. But these application are designed to pop up a Dr. Watson dialog (informing that the application has crashed and suggesting to send a report to Microsoft) if they see an unhandled and unrecognized exception come their way. And they do! So, if you were seeing that Document.Close causes host application to crash this is why.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Another variation of "unhandled exception in reverse P/Invoke" crash is when your are debugging Word/Excel and there is an unhandled exception thrown from Button.Click event handler. Normally WinForms would internally catch unhandled exceptions but debugging mode is special cased.&amp;nbsp; When WinForms detect managed debugger is attached they would let the exception go through to benefit from the Visual Studio debugger behavior which always breaks on unhandled exceptions. But when WinForms are hosted inside native application this trick causes crashes. In order to force WinForms into always catching the exception just install an event handler for System.Windows.Forms.Application.ThreadException event.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Those crashes were a big bummer for VSTO. Starting with VSTO v2 Beta2 you would not (usually :)) see those crashes. What is the trick? We decided that we want to be in control. If managed WndProc misbehaves we are going to deal with it right away without letting the SEH propagate and destabilize the entire application. Our VSTO loader sub-classes every WinForms "managed" window and redirects the WndProc to our own native WndProc. The latter calls into original managed WndProc and if the SEH is thrown we just swallow it. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Some internal implementation details (that are not guaranteed to stay this way in the future but this is the way things are now). We sub-class the window inside WH_CALLWNDPROCRET windows hook after WM_CREATE message is processed by WinForms. We check whether an HWND belongs to our AppDomain by calling System.Windows.Forms.NativeWindow.FromHandle(hwnd) from inside the AppDomain. The original WndProc is stuffed into GWL_USERDATA slot in the window. &lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=442866" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category></item><item><title>Menus for VSTO Smart Tags are dynamic</title><link>http://blogs.msdn.com/mshneer/archive/2005/07/21/441428.aspx</link><pubDate>Thu, 21 Jul 2005 20:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:441428</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/441428.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=441428</wfw:commentRss><description>&lt;FONT face=Verdana color=#800080 size=2&gt;
&lt;P&gt;One quick tip today. Since VSTO Beta2 we have added SmartTags support for document level customizations. How to create those is covered by Paul Stubbs &lt;a href="http://blogs.msdn.com/pstubbs/archive/2005/03/30/403801.aspx"&gt;here&lt;/A&gt; and in a video tutorial &lt;a href="http://blogs.msdn.com/vsto2/archive/2005/02/09/370198.aspx"&gt;here&lt;/A&gt; . However what is not obvious is that one can dynamically change the caption on the menu items displayed for a particular SmartTag.&amp;nbsp;The SmartTag class has a collection of Actions that represent the menu item. The Action class exposes BeforeCaptionShow event. One can register an event handler for this event. In the event handler just change the value of your Action.Caption property to whatever string value you want. Since the tagged text, the property bag and the either Word's or Excel's Range object are passed in as parameters you can make quite educated decision about what the caption should be. If you set the value to an empty string (either null or String.Empty) the corresponding menu item would not appear at all. On the related note, do not use this event handler for actually modifying the range object. This event is only designed to get values from the OM and set the Caption property.&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=441428" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category></item></channel></rss>