<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: When to release COM objects in Office add-ins developed in .NET</title>
	<atom:link href="http://www.add-in-express.com/creating-addins-blog/2008/10/30/releasing-office-objects-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.add-in-express.com/creating-addins-blog/2008/10/30/releasing-office-objects-net/</link>
	<description>All about developing COM add-ins, smart tags and RTD servers in Visual Studio .NET, VSTO and Delphi + Add-in Express</description>
	<lastBuildDate>Wed, 08 Feb 2012 13:13:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Andrei Smolin</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2008/10/30/releasing-office-objects-net/comment-page-1/#comment-11094</link>
		<dc:creator>Andrei Smolin</dc:creator>
		<pubDate>Wed, 22 Jun 2011 15:33:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=48#comment-11094</guid>
		<description>Hello Robert,

That article covers developing add-ins for Visual Studio. It doesn&#039;t relate to developing Office add-ins. 

As I said above &quot;The reaction to not releasing a COM reference depends on the implementation of the corresponding COM server.&quot;

From today&#039;s email, on results of releasing COM objects: &quot;I had to refactor the code a little bit to load a TaskItem only when it is needed and release it shortly after but once all references to TaskItems were released the strange behavior disappeared. Who would have thought that the underlying COM implementation could be this tricky??&quot;

Note that they discuss getting COM objects by two add-ins (for Visual Studio!); the add-ins are loaded into the same AppDomain (see Ian Griffiths&#039; remark). That is, their add-ins are non-isolated. You create a non-isolated Office add-in using the Shared Add-in template in the New Project dialog. However, not using non-isolated Office add-ins is a well-known practice. Say, at http://msdn.microsoft.com/en-us/library/aa159894(office.11).aspx they describe the need to use shims as follows: 
   Security. If you set the Office macro security level to High (or Very High in Office 2003), as is recommended, then Office examines the DLLs it loads for digital signatures. When you deploy a managed extension, the DLL that Office examines for signatures is always Mscoree.dll. This is the .NET common language runtime (CLR) engine, which in turn loads your custom managed extension DLL. The problem is that you cannot digitally sign Mscoree.dll. Therefore, you need to interpose a COM shim DLL, which you can sign, as the first DLL that Office examines for signatures.
   Isolation. If you do not use a standard COM shim (such as the Visual Studio Tools for Office loader) or provide your own custom COM shim, your extension DLL loads into the default application domain along with all other un-shimmed extensions. All DLLs running in the same application domain are vulnerable to potential damage caused by any other DLL in the same application domain. Also, any un-shimmed add-in that crashes in a host application disables all other un-shimmed add-ins for that application.

One of the potential damages mentioned above is that an add-in may release a COM object used by another add-in; exactly the same scenario is discussed in the article you are referring to.</description>
		<content:encoded><![CDATA[<p>Hello Robert,</p>
<p>That article covers developing add-ins for Visual Studio. It doesn&#8217;t relate to developing Office add-ins. </p>
<p>As I said above &#8220;The reaction to not releasing a COM reference depends on the implementation of the corresponding COM server.&#8221;</p>
<p>From today&#8217;s email, on results of releasing COM objects: &#8220;I had to refactor the code a little bit to load a TaskItem only when it is needed and release it shortly after but once all references to TaskItems were released the strange behavior disappeared. Who would have thought that the underlying COM implementation could be this tricky??&#8221;</p>
<p>Note that they discuss getting COM objects by two add-ins (for Visual Studio!); the add-ins are loaded into the same AppDomain (see Ian Griffiths&#8217; remark). That is, their add-ins are non-isolated. You create a non-isolated Office add-in using the Shared Add-in template in the New Project dialog. However, not using non-isolated Office add-ins is a well-known practice. Say, at <a href="http://msdn.microsoft.com/en-us/library/aa159894(office.11).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa159894(office.11).aspx</a> they describe the need to use shims as follows:<br />
   Security. If you set the Office macro security level to High (or Very High in Office 2003), as is recommended, then Office examines the DLLs it loads for digital signatures. When you deploy a managed extension, the DLL that Office examines for signatures is always Mscoree.dll. This is the .NET common language runtime (CLR) engine, which in turn loads your custom managed extension DLL. The problem is that you cannot digitally sign Mscoree.dll. Therefore, you need to interpose a COM shim DLL, which you can sign, as the first DLL that Office examines for signatures.<br />
   Isolation. If you do not use a standard COM shim (such as the Visual Studio Tools for Office loader) or provide your own custom COM shim, your extension DLL loads into the default application domain along with all other un-shimmed extensions. All DLLs running in the same application domain are vulnerable to potential damage caused by any other DLL in the same application domain. Also, any un-shimmed add-in that crashes in a host application disables all other un-shimmed add-ins for that application.</p>
<p>One of the potential damages mentioned above is that an add-in may release a COM object used by another add-in; exactly the same scenario is discussed in the article you are referring to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Cowham</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2008/10/30/releasing-office-objects-net/comment-page-1/#comment-11084</link>
		<dc:creator>Robert Cowham</dc:creator>
		<pubDate>Tue, 21 Jun 2011 13:32:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=48#comment-11084</guid>
		<description>Does your advice here still hold true?

What about this article:

http://blogs.msdn.com/b/visualstudio/archive/2010/03/01/marshal-releasecomobject-considered-dangerous.aspx</description>
		<content:encoded><![CDATA[<p>Does your advice here still hold true?</p>
<p>What about this article:</p>
<p><a href="http://blogs.msdn.com/b/visualstudio/archive/2010/03/01/marshal-releasecomobject-considered-dangerous.aspx" rel="nofollow">http://blogs.msdn.com/b/visualstudio/archive/2010/03/01/marshal-releasecomobject-considered-dangerous.aspx</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

