<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.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>Carlos Quintero blog</title><link>http://msmvps.com/blogs/carlosq/default.aspx</link><description>Visual Studio Extensibility with Add-ins</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Debugging .NET Framework working only "sometimes"</title><link>http://msmvps.com/blogs/carlosq/archive/2013/04/10/debugging-net-framework-working-only-quot-sometimes-quot.aspx</link><pubDate>Wed, 10 Apr 2013 17:35:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1827010</guid><dc:creator>carlosq</dc:creator><slash:comments>1</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/04/10/debugging-net-framework-working-only-quot-sometimes-quot.aspx#comments</comments><description>&lt;p&gt;I am these days (well, nights) debugging an extremely difficult issue with the ImageList control and I had that idea that debugging the .NET Framework (source step) would help a lot. That feature was introduced in VS 2008 and my feeling these years when I tested it from time to time was that sometimes it worked, sometimes it didn&amp;#39;t. Yesterday that I needed it badly I searched the web and I discovered that I was not alone. There are tons of issues and workarounds about it. I tried all them to no avail.&lt;/p&gt;
&lt;p&gt;Finally someone from Microsoft posted &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/refsourceserver/thread/41388c7b-582b-4e3f-8178-3d38a3c99639"&gt;here&lt;/a&gt; (only a few weeks ago after all these years!) that the root cause is out-of-date PDBs, and that it is going to happen each time that Microsoft releases a new build of an assembly, which is not only in service packs but also any security patch. Since there is cadence between the release of the assembly and the release of the PDB (that has been up to 1 year in the past!), this feature is basically broken, bad designed.&lt;/p&gt;
&lt;p&gt;The alternative, suggested strongly by that guy, is to use &lt;a href="http://www.red-gate.com/products/dotnet-development/reflector/"&gt;.NET Reflector&lt;/a&gt;, a paid tool which for developers of Visual Studio extensions is even more useful to debug Visual Studio assemblies (not just .NET Framework assemblies) as I explained in &lt;a href="http://www.red-gate.com/products/dotnet-development/reflector/guest-post"&gt;this guest post&lt;/a&gt; on their blog.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1827010" width="1" height="1"&gt;</description></item><item><title>Msaddndr.dll file officially not installed by Microsoft Office 2013</title><link>http://msmvps.com/blogs/carlosq/archive/2013/04/06/msaddndr-dll-file-not-installed-by-office-2013.aspx</link><pubDate>Sat, 06 Apr 2013 08:30:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1826688</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/04/06/msaddndr-dll-file-not-installed-by-office-2013.aspx#comments</comments><description>&lt;p&gt;As I posted back in November, &lt;a href="http://msmvps.com/blogs/carlosq/archive/2012/11/11/the-strange-case-of-error-quot-unable-to-register-dll-ocx-regsvr32-failed-with-exit-code-0x5-quot.aspx"&gt;the setup of an add-in for the VBA editor of Office 2013 written with VB6 could fail with the following error&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&amp;quot;Unable to register DLL/OCX:RegSvr32 failed with exit code 0x5&amp;quot;&lt;/p&gt;
&lt;p&gt;I mentioned that the cause was that the file Msaddndr.dll is no longer installed by Office 2013 and today I have found that Microsoft wrote an official Knowledge Base (KB) article stating it a month later:&lt;/p&gt;
&lt;p&gt;A custom add-in that uses interfaces in the Msaddndr.dll file does not work in Office 2013&lt;br /&gt;&lt;a href="http://support.microsoft.com/kb/2792179"&gt;http://support.microsoft.com/kb/2792179&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The workaround is, of course, that your setup installs that file. BTW, I got yesterday a bug report from a user of my &lt;a href="http://www.mztools.com"&gt;MZ-Tools 3.0 for VBA&lt;/a&gt; with that same error but using a MZTools3VBASetup.exe that already (supposedly) installed the file. It happened that the system already had that file installed, but an old version, and the setup only installed it if not present, so it was not replaced by the newest version. So, when applying this workaround, ensure that your setup installs the file if not present, or if it is an older version, because it seems that there are at least two versions of Msaddndr.dll out there.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1826688" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/carlosq/archive/tags/VBA+add-ins/default.aspx">VBA add-ins</category></item><item><title>Windows PowerShell scripts to register a .NET-based add-in for a COM-based host application</title><link>http://msmvps.com/blogs/carlosq/archive/2013/03/28/windows-powershell-scripts-to-register-a-net-based-add-in-for-a-com-based-host-application.aspx</link><pubDate>Wed, 27 Mar 2013 22:03:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1825971</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/03/28/windows-powershell-scripts-to-register-a-net-based-add-in-for-a-com-based-host-application.aspx#comments</comments><description>&lt;p&gt;Before Visual Studio 2005 introduced XML-based registration for add-ins with an .AddIn file (which enabled X-Copy deployment), add-ins for Microsoft applications required two steps to be registered:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To register the add-in dll as ActiveX (COM) component&lt;/li&gt;
&lt;li&gt;To register the add-in dll as add-in for the host application through some registry entries&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is still true for COM-based add-ins for Visual Studio (any version) and for other hosts such as Microsoft Office or its VBA editor which only support COM-based add-ins.&lt;/p&gt;
&lt;p&gt;Some months ago &lt;a href="http://msmvps.com/blogs/carlosq/archive/tags/VBA+add-ins/default.aspx"&gt;I wrote how to create a COM add-in for the VBA editor of Office using .NET&lt;/a&gt;, which is almost the only way to create an add-in for the VBA editor of Office 64-bit, &lt;a href="http://msdn.microsoft.com/en-us/library/ee691831.aspx#odc_office2010_Compatibility32bit64bit_ActiveXControlCOMAddinCompatibility"&gt;since it doesn&amp;#39;t support 32-bit COM add-ins&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I am working since some months ago on a .NET-based version of my &lt;a href="http://www.mztools.com"&gt;MZ-Tools add-in&lt;/a&gt; for the VBA editor of Office 32/64-bit and I always wanted a single script to perform the two steps above. This was a nice excuse to learn &lt;a href="http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx"&gt;Windows PowerShell&lt;/a&gt;, so I bought a book and after reading some chapters to get the concepts today I decided to create the scripts that call regasm.exe to register the .Net assembly for COM-Interop and create the registry entries for the add-in to be recognized by the VBA editor:&lt;/p&gt;
&lt;p&gt;1) This is the content of a file named Functions.ps1 which contains reusable functions:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;# To run .ps1 scripts you need to execute first: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned&lt;br /&gt;&lt;br /&gt;[System.Reflection.Assembly]::LoadWithPartialName(&amp;quot;System.Windows.Forms&amp;quot;)&lt;br /&gt;$Regasm32 = &amp;#39;C:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm.exe&amp;#39;&lt;br /&gt;$Regasm64 = &amp;#39;C:\Windows\Microsoft.NET\Framework64\v2.0.50727\regasm.exe&amp;#39;&lt;br /&gt;&lt;br /&gt;function Register-Assembly32([string]$Assembly, [string]$RegistryKey, [string]$FriendlyName)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; Execute-Command -RegAsm $Regasm32&amp;nbsp; -Arguments &amp;#39;/codebase&amp;#39; -Assembly $Assembly&lt;br /&gt;&amp;nbsp;&amp;nbsp; Register-AddIn -RegistryKey $RegistryKey -FriendlyName $FriendlyName&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function Register-Assembly64([string]$Assembly, [string]$RegistryKey, [string]$FriendlyName)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; Execute-Command -RegAsm $Regasm64 -Arguments &amp;#39;/codebase&amp;#39; -Assembly $Assembly&lt;br /&gt;&amp;nbsp;&amp;nbsp; Register-AddIn -RegistryKey $RegistryKey -FriendlyName $FriendlyName&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function Unregister-Assembly32([string]$Assembly, [string]$RegistryKey)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; Execute-Command -RegAsm $Regasm32 -Arguments &amp;#39;/unregister&amp;#39; -Assembly $Assembly&lt;br /&gt;&amp;nbsp;&amp;nbsp; Unregister-AddIn -RegistryKey $RegistryKey&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function Unregister-Assembly64([string]$Assembly, [string]$RegistryKey)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; Execute-Command -RegAsm $RegAsm64 -Arguments &amp;#39;/unregister&amp;#39; -Assembly $Assembly&lt;br /&gt;&amp;nbsp;&amp;nbsp; Unregister-AddIn -RegistryKey $RegistryKey&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function Register-AddIn([string]$RegistryKey, [string]$FriendlyName)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; New-Item&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Path $RegistryKey -Force&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; New-ItemProperty -Path $RegistryKey -Name Description&amp;nbsp; -PropertyType String -Value $FriendlyName&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; New-ItemProperty -Path $RegistryKey -Name FriendlyName -PropertyType String -Value $FriendlyName&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; New-ItemProperty -Path $RegistryKey -Name LoadBehavior -PropertyType DWord&amp;nbsp; -Value 3&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function Unregister-AddIn([string]$RegistryKey)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Test-Path -Path $RegistryKey)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Remove-Item -Path $RegistryKey&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function Execute-Command([string]$RegAsm, [string]$Arguments, [string]$Assembly)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $psi = New-Object System.Diagnostics.ProcessStartInfo&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $psi.CreateNoWindow = $true&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $psi.UseShellExecute = $false&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $psi.RedirectStandardOutput = $true&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $psi.RedirectStandardError = $true&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $psi.FileName = $RegAsm&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $psi.Arguments = $Arguments + &amp;#39; &amp;#39; + $Assembly&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $process = New-Object System.Diagnostics.Process&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $process.StartInfo = $psi&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [void]$process.Start()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $StandardOutput = $process.StandardOutput.ReadToEnd()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $StandardError = $process.StandardError.ReadToEnd()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $process.WaitForExit()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [system.windows.forms.messagebox]::show($StandardOutput + $StandardError)&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;2) Then I have other scripts that include that script:&lt;/p&gt;
&lt;p&gt;MyAddInVBA32Registration.ps1:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$ScriptDirectory = Split-Path $MyInvocation.MyCommand.Path&lt;br /&gt;. (Join-Path $ScriptDirectory Functions.ps1)&lt;br /&gt;&lt;br /&gt;$Assembly = (get-item Env:\USERPROFILE).Value + &amp;#39;\Documents\MyAddIn\Exe\Debug\MyAddIn.dll&amp;#39;&lt;br /&gt;&lt;br /&gt;Register-Assembly32 -Assembly $Assembly -RegistryKey &amp;#39;HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns\MyAddIn.Connect&amp;#39; -FriendlyName &amp;#39;My Add-In&amp;#39;&lt;/p&gt;
&lt;p&gt;MyAddInVBA64Registration.ps1:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$ScriptDirectory = Split-Path $MyInvocation.MyCommand.Path&lt;br /&gt;. (Join-Path $ScriptDirectory Functions.ps1)&lt;br /&gt;&lt;br /&gt;$Assembly = (get-item Env:\USERPROFILE).Value + &amp;#39;\Documents\MyAddIn\Exe\Debug\MyAddIn.dll&amp;#39;&lt;br /&gt;&lt;br /&gt;Register-Assembly64
 -Assembly $Assembly -RegistryKey 
&amp;#39;HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns64\MyAddIn.Connect&amp;#39; 
-FriendlyName &amp;#39;My Add-In&amp;#39;&lt;/p&gt;
&lt;p&gt;MyAddInVBA32Unregistration.ps1:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$ScriptDirectory = Split-Path $MyInvocation.MyCommand.Path&lt;br /&gt;. (Join-Path $ScriptDirectory Functions.ps1)&lt;br /&gt;&lt;br /&gt;$Assembly = (get-item Env:\USERPROFILE).Value + &amp;#39;\Documents\MyAddIn\Exe\Debug\MyAddIn.dll&amp;#39;&lt;br /&gt;&lt;br /&gt;Unregister-Assembly32
 -Assembly $Assembly -RegistryKey 
&amp;#39;HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns\MyAddIn.Connect&amp;#39;&lt;/p&gt;
&lt;p&gt;MyAddInVBA64Unregistration.ps1:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$ScriptDirectory = Split-Path $MyInvocation.MyCommand.Path&lt;br /&gt;. (Join-Path $ScriptDirectory Functions.ps1)&lt;br /&gt;&lt;br /&gt;$Assembly = (get-item Env:\USERPROFILE).Value + &amp;#39;\Documents\MyAddIn\Exe\Debug\MyAddIn.dll&amp;#39;&lt;br /&gt;&lt;br /&gt;Unregister-Assembly64
 -Assembly $Assembly -RegistryKey 
&amp;#39;HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns64\MyAddIn.Connect&amp;#39;&lt;/p&gt;
&lt;p&gt;To run the scripts you need to enable PowerShell execution first and they need to be run with admin rights.&lt;/p&gt;
&lt;p&gt;I am finding PowerShell with a learning curve harder than expected and with some &amp;quot;by-design&amp;quot; issues that makes it &amp;quot;tricky&amp;quot; in my opinion, but I hope to learn it in depth.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1825971" width="1" height="1"&gt;</description></item><item><title>MZ-Tools Articles Series updated</title><link>http://msmvps.com/blogs/carlosq/archive/2013/03/26/mz-tools-articles-series-updated.aspx</link><pubDate>Tue, 26 Mar 2013 13:45:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1825868</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/03/26/mz-tools-articles-series-updated.aspx#comments</comments><description>&lt;p&gt;Many of the &lt;a href="http://www.mztools.com/resources_vsnet_addins.aspx#MZToolsArticles"&gt;MZ-Tools Articles&lt;/a&gt; that I have written in the last years seemed a bit outdated because each one has a header like this:&lt;/p&gt;
&lt;table style="height:74px;" border="0" width="648"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Author&lt;/b&gt;: &lt;/td&gt;
&lt;td&gt;Carlos J. Quintero (Microsoft MVP)&lt;/td&gt;
&lt;td class="td_article_header"&gt;&lt;b&gt;Applies to&lt;/b&gt;:&lt;/td&gt;
&lt;td&gt;Microsoft Visual Studio .NET 2002&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Date&lt;/b&gt;:&lt;/td&gt;
&lt;td&gt;March 2010&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;Microsoft Visual Studio .NET 2003&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;br /&gt;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;Microsoft Visual Studio 2005&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Where the date and the list of Visual Studio versions would reflect the moment in time when I wrote them.&lt;/p&gt;
&lt;p&gt;I have reviewed all them (200+) and many are now updated to reflect that they apply until the last Visual Studio 2012 version when that is the case:&lt;/p&gt;
&lt;table style="height:130px;" border="0" width="652"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Author&lt;/b&gt;: &lt;/td&gt;
&lt;td&gt;Carlos J. Quintero (Microsoft MVP)&lt;/td&gt;
&lt;td class="td_article_header"&gt;&lt;b&gt;Applies to&lt;/b&gt;:&lt;/td&gt;
&lt;td&gt;Microsoft Visual Studio .NET 2002&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Date&lt;/b&gt;:&lt;/td&gt;
&lt;td&gt;March 2010&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;Microsoft Visual Studio .NET 2003&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Updated:&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;March 2013&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;Microsoft Visual Studio 2005&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;Microsoft Visual Studio 2008&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;Microsoft Visual Studio 2010&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;Microsoft Visual Studio 2012&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So, most HOWTO articles are now current. The exceptions are those articles which are BUG or PRB (issue), that I haven&amp;#39;t bothered to check if they are still present.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1825868" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/carlosq/archive/tags/MZ-Tools+Articles+Series/default.aspx">MZ-Tools Articles Series</category></item><item><title>MZ-Tools Articles Series: BUG: DTE.ActiveDocument.ActiveWindow does not return the active document window if toolwindow active</title><link>http://msmvps.com/blogs/carlosq/archive/2013/03/17/mz-tools-articles-series-bug-dte-activedocument-activewindow-does-not-return-the-active-document-window-if-toolwindow-active.aspx</link><pubDate>Sun, 17 Mar 2013 16:18:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1825366</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/03/17/mz-tools-articles-series-bug-dte-activedocument-activewindow-does-not-return-the-active-document-window-if-toolwindow-active.aspx#comments</comments><description>&lt;p&gt;My first small article this year is to document this bug of Visual Studio 2005, 2008, 2010 and 2012:&lt;/p&gt;
&lt;p&gt;BUG: DTE.ActiveDocument.ActiveWindow does not return the active document window if toolwindow active&lt;br /&gt;&lt;a href="http://www.mztools.com/articles/2013/MZ2013001.aspx"&gt;http://www.mztools.com/articles/2013/MZ2013001.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Which I have just reported to Microsoft Connect:&lt;/p&gt;
&lt;p&gt;Document.ActiveWindow does not return always the active window&lt;br /&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/781522/document-activewindow-does-not-return-always-the-active-window"&gt;https://connect.microsoft.com/VisualStudio/feedback/details/781522/document-activewindow-does-not-return-always-the-active-window&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;and that is a variation of a bug that I reported for VS.NET 2002/2003 and that I thought it was definitely fixed in VS 2005 (the relevant factor is that it still fails if a toolwindow is active):&lt;/p&gt;
&lt;p&gt;BUG: Document.ActiveWindow does not return always the active window in Visual Studio .NET 2002/2003&lt;br /&gt;&lt;a href="http://www.mztools.com/articles/2004/MZ2004013.aspx"&gt;http://www.mztools.com/articles/2004/MZ2004013.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1825366" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/carlosq/archive/tags/MZ-Tools+Articles+Series/default.aspx">MZ-Tools Articles Series</category></item><item><title>The strange case of "LoaderLock was detected" with a COM add-in written in .NET</title><link>http://msmvps.com/blogs/carlosq/archive/2013/03/17/the-strange-case-of-quot-loaderlock-was-detected-quot-with-a-com-add-in-written-in-net.aspx</link><pubDate>Sun, 17 Mar 2013 00:07:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1825334</guid><dc:creator>carlosq</dc:creator><slash:comments>1</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/03/17/the-strange-case-of-quot-loaderlock-was-detected-quot-with-a-com-add-in-written-in-net.aspx#comments</comments><description>&lt;p&gt;Since some days ago, I was getting the following error when closing Visual Basic 6.0 from the Visual Studio debugger (I am developing a .NET-based version of MZ-Tools for the 64-bit VBA editor of Office, and VB6 will get it too):&lt;/p&gt;
&lt;p&gt;&lt;i&gt;LoaderLock was detected&lt;br /&gt;Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;This is a warning of the Managed Debugging Assistants (MDA) of Visual Studio.&lt;/p&gt;
&lt;p&gt;Today I decided to investigate. Soon it was clear that it was caused by the test-runner add-in that I created to run integration tests within VB 6.0. Since the error was caused during shutdown, I removed initializations (and the corresponding cleanups) to isolate the problem and I discovered that the problem was in this method:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal List&amp;lt;string&amp;gt; GetAddinProgIds()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;string&amp;gt; colAddinProgIds;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; colAddinProgIds = new List&amp;lt;string&amp;gt;();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (AddIn objAddIn in m_objVBE.Addins)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; colAddinProgIds.Add(objAddIn.ProgId);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return colAddinProgIds;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;That method gets the registered add-ins of the VBE object (to load them in a combobox and select an add-in to run its test suites).&lt;/p&gt;
&lt;p&gt;I soon realized that maybe I should release propertly some COM object and certainly the problem was fixed:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal List&amp;lt;string&amp;gt; GetAddinProgIds()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;string&amp;gt; colAddinProgIds;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Addins colAddins;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; colAddinProgIds = new List&amp;lt;string&amp;gt;();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; colAddins = m_objVBE.Addins;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (AddIn objAddIn in colAddins)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; colAddinProgIds.Add(objAddIn.ProgId);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // The following statement is to prevent the following error:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // LoaderLock was detected&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // or image initialization function since doing so can cause the application to hang.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Runtime.InteropServices.Marshal.ReleaseComObject(colAddins);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; colAddins = null;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return colAddinProgIds;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1825334" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/carlosq/archive/tags/The+strange+case+of_2E00__2E00__2E00_/default.aspx">The strange case of...</category></item><item><title>The strange case of "Set property 'System.Windows.ResourceDictionary.DeferrableContent' threw an exception."</title><link>http://msmvps.com/blogs/carlosq/archive/2013/03/09/the-strange-case-of-quot-set-property-system-windows-resourcedictionary-deferrablecontent-threw-an-exception-quot.aspx</link><pubDate>Sat, 09 Mar 2013 21:43:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1824934</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/03/09/the-strange-case-of-quot-set-property-system-windows-resourcedictionary-deferrablecontent-threw-an-exception-quot.aspx#comments</comments><description>&lt;p&gt;In the recent days, each time that I clicked the New Project button of the Visual Studio 2012 IDE, I got this exception:&lt;/p&gt;
&lt;p&gt;&amp;quot;Set property &amp;#39;System.Windows.ResourceDictionary.DeferrableContent&amp;#39; threw an exception.&amp;quot;&lt;/p&gt;
&lt;p&gt;I have been clueless about this problem until today. When a problem happens in Visual Studio, the recommended approach is to launch it in &amp;quot;Safe mode&amp;quot;, because maybe an extension (add-in, package, etc.) is causing it. As a previous step, what I did today is to take a look at the Add-In Manager and I noticed that I had an add-in (a test runner that I created to perform integration tests of my &lt;a href="http://www.mztools.com"&gt;MZ-Tools&lt;/a&gt; add-in) marked to load on startup. I unmarked it and then the problem disappeared. Why was this add-in causing this problem?&lt;/p&gt;
&lt;p&gt;After some isolation, it happened that this add-in was setting an event handler for the AppDomain.AssemblyResolve event (to locate required assemblies) and a silenced NullReferenceException was happening in the event handler. The following minimal add-in reproduces the issue:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public class Connect : IDTExtensibility2&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private DTE2 _applicationObject;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private AddIn _addInInstance;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private AppDomain _appDomain;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _applicationObject = (DTE2)application;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _addInInstance = (AddIn)addInInst;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch (connectMode)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case ext_ConnectMode.ext_cm_Startup:&lt;br /&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; // OnStartupComplete will be called&lt;br /&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; break;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case ext_ConnectMode.ext_cm_AfterStartup:&lt;br /&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; InitializeAddIn();&lt;br /&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; break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void OnStartupComplete(ref Array custom)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeAddIn();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void InitializeAddIn()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _appDomain = AppDomain.CurrentDomain;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _appDomain.AssemblyResolve += AppDomain_AssemblyResolve;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void OnDisconnection(ext_DisconnectMode disconnectMode, ref Array custom)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _appDomain.AssemblyResolve -= AppDomain_AssemblyResolve;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public void OnAddInsUpdate(ref Array custom)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public void OnBeginShutdown(ref Array custom)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Assembly AppDomain_AssemblyResolve(object sender, ResolveEventArgs args)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Assembly objAssembly = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AssemblyName objAssemblyName = null;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Force a NullReferenceException&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (objAssemblyName.Name == &amp;quot;&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return objAssembly;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1824934" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/carlosq/archive/tags/The+strange+case+of_2E00__2E00__2E00_/default.aspx">The strange case of...</category></item><item><title>The strange case of the add-in initialized twice</title><link>http://msmvps.com/blogs/carlosq/archive/2013/02/14/the-strange-case-of-the-add-in-initialized-twice.aspx</link><pubDate>Thu, 14 Feb 2013 19:54:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1823819</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/02/14/the-strange-case-of-the-add-in-initialized-twice.aspx#comments</comments><description>&lt;p&gt;As I commented in my &lt;a href="http://msmvps.com/blogs/carlosq/archive/2013/02/14/long-time-without-blogging.aspx"&gt;last post&lt;/a&gt;, I have developed my own integration test infrastructure to test my &lt;a href="http://www.mztools.com"&gt;MZ-Tools add-in&lt;/a&gt;. As part of it, there is an add-in that is the test runner, that when loaded loads in turn the MZ-Tools add-in if not loaded, locates its friend assembly that contains the integration tests, loads it, gets the test suites, gets the test methods, shows them in a treeview and executes the ones that I select.&lt;/p&gt;
&lt;p&gt;This worked fine if the test runner add-in was not marked to load on startup and I had to load it with the Add-in Manager. But when the test runner add-in was marked to load on startup, the MZ-Tools add-in was initialized twice, giving an exception because some code didn&amp;#39;t expect to run twice (duplicated key).&lt;/p&gt;
&lt;p&gt;The code of the MZ-Tools initialization is similar to the one that I wrote in my article &lt;a href="http://www.mztools.com/articles/2008/MZ2008004.aspx"&gt;HOWTO: Use correctly the OnConnection method of a Visual Studio add-in&lt;/a&gt; and that I constantly recommend in the &lt;a href="http://social.msdn.microsoft.com/forums/en-US/vsx/threads/"&gt;MSDN VSX Forums&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; AddIn _objAddIn;&lt;br /&gt;&amp;nbsp;&amp;nbsp; EnvDTE.DTE _objDTE;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; void IDTExtensibility2.OnConnection(object objApplication, ext_ConnectMode eConnectMode, object objAddInInst, ref System.Array r_objCustom)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _objDTE = (EnvDTE.DTE)objApplication;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _objAddIn = (AddIn)objAddInInst;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch (eConnectMode)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case ext_ConnectMode.ext_cm_Startup:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // IDTExtensibility2.OnStartupComplete will be called&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case ext_ConnectMode.ext_cm_AfterStartup:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Initialize();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; void IDTExtensibility2.OnStartupComplete(ref System.Array r_objCustom)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Initialize();&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; private void Initialize()&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;This pattern assumes that:&lt;/p&gt;
&lt;p&gt;1) If an add-in is loaded on startup:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The OnConnection method will be called with the ext_ConnectMode.ext_cm_Startup flag.&lt;/li&gt;
&lt;li&gt;The OnStartupComplete method will be called later TOO, when the Visual Studio IDE has completed its initialization.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;2) If an add-in is loaded through the Add-In Manager:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The OnConnection method will be called with the 
ext_ConnectMode.ext_cm_AfterStartup flag.&lt;/li&gt;
&lt;li&gt;The OnStartupComplete method will NOT be called (because the Visual Studio IDE was already initialized when you used the Add-In Manager to load the add-in).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But in my case, the Initialize method was being called twice. How was that?&lt;/p&gt;
&lt;p&gt;It happens that there is a subtle behavior here: when an add-in marked to load on startup loads in turn another add-in (using EnvDTE.AddIn.Connect = true), in the second add-in the OnConnection method is called with the ext_ConnectMode.ext_cm_AfterStartup flag, AND the OnStartupComplete is called too!!! (because the Visual Studio IDE was not initialized when the first add-in was loaded on startup). So, the Initialize method is called twice.&lt;/p&gt;
&lt;p&gt;I was about to report this as a bug, but I have thought that maybe the behavior is correct after all, that is, when VS has finished its initialization it calls OnStartupComplete for all add-ins that are loaded in that moment, &lt;i&gt;independently&lt;/i&gt; of whether they were marked to load on startup or they were loaded by another add-in marked to load on startup. And what is really misleading is the &lt;a href="http://msdn.microsoft.com/en-us/library/extensibility.idtextensibility2.onstartupcomplete%28v=vs.110%29.aspx"&gt;MSDN documentation about the OnStartupComplete method&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;(OnStartupComplete) &lt;i&gt;&amp;quot;Occurs whenever an add-in, which is set to load when Visual Studio starts, loads.&amp;quot;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;That implies that if add-in is not set to load on startup, its OnStartupComplete method will not be called.&lt;/p&gt;
&lt;p&gt;The Remarks section is correct, though, since it does not relate the OnStartupComplete call to whether the add-in was set to load on startup or not:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;quot;On occasion, &lt;span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/extensibility.idtextensibility2.onconnection.aspx"&gt;OnConnection&lt;/a&gt;&lt;/span&gt;
 does not occur correctly, such as when an add-in is loaded, but a 
component required by an add-in has not yet loaded. This is unusually 
due to the fact that Visual Studio has not yet started completely. Using
 &lt;span&gt;&lt;span class="selflink"&gt;OnStartupComplete&lt;/span&gt;&lt;/span&gt; guarantees that the  Visual Studio integrated development environment (IDE) has completed the startup process.&amp;quot;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;As you realize, this is a subtlety that your add-in won&amp;#39;t experience unless is loaded by another add-in when Visual Studio is started.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1823819" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/carlosq/archive/tags/The+strange+case+of_2E00__2E00__2E00_/default.aspx">The strange case of...</category></item><item><title>Long time without blogging</title><link>http://msmvps.com/blogs/carlosq/archive/2013/02/14/long-time-without-blogging.aspx</link><pubDate>Thu, 14 Feb 2013 19:03:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1823816</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/02/14/long-time-without-blogging.aspx#comments</comments><description>&lt;p&gt;I have been long time without blogging, and the reason is that I have been quite busy doing the following:&lt;/p&gt;
&lt;p&gt;- I have migrated the whole code of my &lt;a href="http://www.mztools.com"&gt;MZ-Tools 7.0 add-in&lt;/a&gt; from VB.NET to C#. After 10 years programming in VB.NET, I decided to switch to C# and the best way is to use it everyday, so I had to migrate the product. The migration was successful and build 7.0.0.103 released on December 1 was C#-based. Only a couple of bugs were introduced that were not detected by the automated integration tests. FWIW, I used &lt;a href="http://www.tangiblesoftwaresolutions.com/Product_Details/Instant_CSharp.html"&gt;Instant C# from Tangible Software Solutions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;- I have enforced the Code Analysis feature of Visual Studio on the MZ-Tools code base with All Microsoft Rules, and after lots of fixes I was able to pass all with some custom suppressions and four of them disabled: &lt;a href="http://msdn.microsoft.com/en-us/library/ms182137.aspx"&gt;CA1031 Do not catch general exception types&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/ms182212.aspx"&gt;CA1502 Avoid excessive complexity&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/bb397994.aspx"&gt;CA1506 Avoid excessive class coupling&lt;/a&gt; and CA5122 P/Invoke declarations should not be safe-critical. If you have tried to enforce them on a large code base you know how time-consuming is that.&lt;/p&gt;
&lt;p&gt;- I have done massive architectural changes in the code base of MZ-Tools for Visual Studio to prepare a new unified version 8.0, .NET-based, that will support Visual Studio (VB.NET, C#), Visual Basic 6.0 (&amp;quot;Classic&amp;quot;), VBA editor of Office 32-bit and VBA editor of Office 64-bit. That means to encapsulate the automation models of VS and VB &amp;quot;classic&amp;quot;. I already have the user interface, options, setup and unit-test/integration-test subsystems. It &amp;quot;only&amp;quot; remains the features, but it will take me months yet :-). I will blog about this in the next months when I am closer to the release.&lt;/p&gt;
&lt;p&gt;- I have created an integration test runner that runs in the IDE where MZ-Tools is loaded, rather than in the IDE where the MZ-Tools source code project is loaded. While the Visual Studio SDK provides a remote MS-Test-based host adapter for this purpose, I tried it two years ago with disappointing results, so I created my own integration testing infrastructure in MZ-Tools. But the MZ-Tools add-in, its integration tests and the test-runner were in the same assembly (using a special configuration). Now I have isolated them so I have the add-in, the integration tests and the test-runner in three separate assemblies. I hope to release the test runner in CodePlex or similar some day.&lt;/p&gt;
&lt;p&gt;- I migrated to Visual Studio 2012 (I am almost used to the new UI style) and I am planning to adopt TFS (I am finishing the simultaneous reading of &lt;a href="http://www.amazon.com/Professional-Team-Foundation-Server-2012/dp/1118314093"&gt;Professional Team Foundation Server 2012&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/jj159345.aspx"&gt;Testing for Continuous Delivery with Visual Studio 2012&lt;/a&gt;). In the past I used &lt;a href="http://www.perforce.com/"&gt;Perforce&lt;/a&gt;, but after a failed restore after a crash (likely my fault) I didn&amp;#39;t use source control for some time and I want to adopt TFS now.&lt;/p&gt;
&lt;p&gt;And I was almost three weeks on vacation during Christmas, resting and watching lots of TV series :-)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1823816" width="1" height="1"&gt;</description></item><item><title>The 10-years MVP custom disk from Microsoft</title><link>http://msmvps.com/blogs/carlosq/archive/2013/02/14/the-10-years-mvp-custom-disk-from-microsoft.aspx</link><pubDate>Thu, 14 Feb 2013 18:51:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1823815</guid><dc:creator>carlosq</dc:creator><slash:comments>2</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/02/14/the-10-years-mvp-custom-disk-from-microsoft.aspx#comments</comments><description>&lt;p&gt;I have just received the 10-years MVP custom disk from Microsoft :-)&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;quot;Congratulations! In recognition of your longstanding community 
contributions as a Microsoft MVP, Microsoft is honoring your achievement
 with a custom award disk to add to your MVP Crystal Wedge Award.&lt;/i&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/carlosq/6787.MVPTenYears.JPG"&gt;&lt;img src="http://msmvps.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/carlosq/6787.MVPTenYears.JPG" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1823815" width="1" height="1"&gt;</description></item><item><title>10 years as Microsoft Most Valuable Professional (MVP) </title><link>http://msmvps.com/blogs/carlosq/archive/2013/01/01/10-years-as-microsoft-most-valuable-professional-mvp.aspx</link><pubDate>Tue, 01 Jan 2013 17:25:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1821930</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2013/01/01/10-years-as-microsoft-most-valuable-professional-mvp.aspx#comments</comments><description>&lt;p&gt;Happy New Year!&lt;/p&gt;
&lt;p&gt;I have received a new Most Valuable Professional (MVP) award from Microsoft just a couple of hours ago. This is a very special one for me because it is my 10th MVP award and, as always, I am very grateful to Microsoft for this recognition:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;quot;Dear Carlos Quintero,&lt;br /&gt;&lt;br /&gt;
Congratulations! We are pleased to present you with the 2013 Microsoft&amp;reg; 
MVP Award! This award is given to exceptional technical community 
leaders who actively share their high quality, real world expertise with
 others. We appreciate your outstanding contributions in Visual Basic 
technical communities during the past year.&amp;quot;&lt;/i&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1821930" width="1" height="1"&gt;</description></item><item><title>A wrong way of checking the Visual Studio version where an add-in is loaded</title><link>http://msmvps.com/blogs/carlosq/archive/2012/12/10/a-wrong-way-of-checking-the-visual-studio-version-where-an-add-in-is-loaded.aspx</link><pubDate>Mon, 10 Dec 2012 22:26:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1820691</guid><dc:creator>carlosq</dc:creator><slash:comments>2</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2012/12/10/a-wrong-way-of-checking-the-visual-studio-version-where-an-add-in-is-loaded.aspx#comments</comments><description>&lt;p&gt;Take a look at this code of an add-in that checks that it is loaded only in Visual Studio 2012 and try to figure out what&amp;#39;s wrong:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private DTE2 _applicationObject;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private AddIn _addInInstance;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; const string REGISTRY_KEY_VS_11_0 = &amp;quot;SOFTWARE\\MICROSOFT\\VISUALSTUDIO\\11.0&amp;quot;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string addInRegistryRoot = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _applicationObject = (DTE2)application;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _addInInstance = (AddIn)addInInst;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch (connectMode)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case ext_ConnectMode.ext_cm_AfterStartup:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case ext_ConnectMode.ext_cm_Startup:&lt;br /&gt;&lt;br /&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; addInRegistryRoot = _applicationObject.RegistryRoot.ToUpper();&lt;br /&gt;&lt;br /&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; if (!addInRegistryRoot.StartsWith(REGISTRY_KEY_VS_11_0))&lt;br /&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; {&lt;br /&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; System.Windows.Forms.MessageBox.Show(&amp;quot;This add-in only works with Visual Studio 2012&amp;quot;);&lt;br /&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; }&lt;br /&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; break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;If you have discovered it, either you are quite expert on globalization issues or you are a Turkish developer. My &lt;a href="http://www.mztools.com"&gt;MZ-Tools&lt;/a&gt; add-in had similar code that has worked correctly for years until a few weeks ago, when a developer reported that using the Turkish culture (user interface, language input keyboard, etc.) MZ-Tools refused to load. You can simulate that effect inserting the following line at the start the OnConnection method that sets the Turkish culture for the current thread:&lt;/p&gt;
&lt;p&gt;System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(&amp;quot;tr-TR&amp;quot;);&lt;/p&gt;
&lt;p&gt;The reason is that in Turkish, the upper case of the character i is not I but İ (with a dot), as explained &lt;a href="http://www.i18nguy.com/unicode/turkish-i18n.html"&gt;here&lt;/a&gt;. So _applicationObject.RegistryRoot.ToUpper() returns the following string:&lt;/p&gt;
&lt;p&gt;&amp;quot;SOFTWARE\\MİCROSOFT\\VİSUALSTUDİO\\11.0&amp;quot;&lt;/p&gt;
&lt;p&gt;which is different from:&lt;/p&gt;
&lt;p&gt;&amp;quot;SOFTWARE\\MICROSOFT\\VISUALSTUDIO\\11.0&amp;quot;&lt;/p&gt;
&lt;p&gt;Of course, the solution is to use _applicationObject.RegistryRoot.ToUpperInvariant() or an overloaded version of StartsWith() that uses the ordinal or invariant culture comparison ignoring the case.&lt;/p&gt;
&lt;p&gt;So, if you make software for international markets, ensure that you run the Code Analysis feature of Visual Studio with the Microsoft Globalization Rules, because two rules are violated with the code above:&lt;/p&gt;
&lt;p&gt;- CA1304: Specify CultureInfo (in _applicationObject.RegistryRoot.ToUpper())&lt;br /&gt;- CA1307: Specify StringComparison (in sAddInRegistryRoot.StartsWith(REGISTRY_KEY_VS_11_0))&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1820691" width="1" height="1"&gt;</description></item><item><title>The Visual Studio (2012) Image Library</title><link>http://msmvps.com/blogs/carlosq/archive/2012/12/04/the-visual-studio-2012-image-library.aspx</link><pubDate>Tue, 04 Dec 2012 09:07:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1820366</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2012/12/04/the-visual-studio-2012-image-library.aspx#comments</comments><description>&lt;p&gt;Microsoft published some days ago the Visual Studio Image Library:&lt;/p&gt;
&lt;p&gt;&lt;i&gt;The Visual Studio Image Library contains application images that appear in Microsoft Visual Studio, Microsoft Windows, the Office system and other Microsoft software. The library of over 5,000 images can be used to create applications that look visually consistent with Microsoft software.&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=35825"&gt;http://www.microsoft.com/en-us/download/details.aspx?id=35825&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1820366" width="1" height="1"&gt;</description></item><item><title>LearnVSXNow! (about Visual Studio packages), by Istvan Novak (DiveDeeper's blog) </title><link>http://msmvps.com/blogs/carlosq/archive/2012/12/02/learnvsxnow-about-visual-studio-packages-by-istvan-novak-divedeeper-s-blog.aspx</link><pubDate>Sat, 01 Dec 2012 23:03:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1820245</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2012/12/02/learnvsxnow-about-visual-studio-packages-by-istvan-novak-divedeeper-s-blog.aspx#comments</comments><description>&lt;p&gt;MVP fellow Istvan Novak wrote long time ago a long series of small articles about Visual Studio Extensibility (VSX) with packages on his &lt;a href="http://dotneteers.net/blogs/divedeeper/default.aspx"&gt;DiveDeeper&amp;#39;s blog&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;I have added a new section to my &lt;a href="http://www.mztools.com/resources_vsnet_addins.aspx"&gt;Resources about Visual Studio .NET extensibility&lt;/a&gt; page with sorted links to all of them:&lt;/p&gt;
&lt;p&gt;LearnVSXNow!, by Istvan Novak (DiveDeeper&amp;#39;s blog)&lt;br /&gt;&lt;a href="http://www.mztools.com/resources_vsnet_addins.aspx#LearnVSXNow"&gt;http://www.mztools.com/resources_vsnet_addins.aspx#LearnVSXNow&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1820245" width="1" height="1"&gt;</description></item><item><title>Back from Microsoft Tech / Community Day 2012 Madrid</title><link>http://msmvps.com/blogs/carlosq/archive/2012/11/24/back-from-microsoft-tech-comunity-day-2012-madrid.aspx</link><pubDate>Sat, 24 Nov 2012 10:26:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1819788</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2012/11/24/back-from-microsoft-tech-comunity-day-2012-madrid.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;m back from the Microsoft Tech Day / Community Day 2012 at Madrid, which have been great. The aspect that I like most is networking with people, either old MVPs that I already know, new MVPs or other people. &lt;/p&gt;
&lt;p&gt;In this event I was introduced to Jes&amp;uacute;s Salas, the author of &lt;a href="https://vsanywhere.com/default.aspx"&gt;VS Anywhere&lt;/a&gt;&lt;a&gt;&lt;/a&gt;, also available on the &lt;a href="http://visualstudiogallery.msdn.microsoft.com/99466148-ae68-4bd5-b66b-08bae7423a03"&gt;Visual Studio Gallery&lt;/a&gt;, an extension for Visual Studio that provides team collaboration in real time with a very innovative approach.&lt;/p&gt;
&lt;p&gt;I also met my friend Pep Lluis Ba&amp;ntilde;os, Visual Basic MVP like me, who brought to the event an intriguing kind of electronic mini motherboard that happened to be the mainboards used in &lt;a href="http://www.netmf.com/"&gt;.NET Micro Framework&lt;/a&gt;, a technology that I only knew the name. Since I returned, I have been so excited about this technology that I have watched the &lt;a href="http://channel9.msdn.com/Events/Patterns-Practices-Symposium-Online/Patterns-Practices-Symposium-Online-2012/Gadgeteering-and-hte-NET-Micro-Framework"&gt;Gadgeteering and the .NET Micro Framework&lt;/a&gt; video, I have read documentation, I have bought the &lt;a href="http://www.amazon.com/Getting-Started-NET-Gadgeteer-Make/dp/1449328237"&gt;Getting Started with .NET Gadgeteer&lt;/a&gt; book that I am reading and I do plan to buy some &lt;a href="http://www.ghielectronics.com/catalog/category/501/"&gt;.NET Gadgeteer Starter Kit&lt;/a&gt; for Christmas to start playing. It&amp;#39;s great also to see how powerful and flexible Visual Studio and the .NET Framework have become to accommodate all kind of extensions with project types, visual designers for electronic layouts, debuggers with external devices, etc.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1819788" width="1" height="1"&gt;</description></item><item><title>The strange case of error "Unable to register DLL/OCX:RegSvr32 failed with exit code 0x5"</title><link>http://msmvps.com/blogs/carlosq/archive/2012/11/11/the-strange-case-of-error-quot-unable-to-register-dll-ocx-regsvr32-failed-with-exit-code-0x5-quot.aspx</link><pubDate>Sun, 11 Nov 2012 22:46:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1819068</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2012/11/11/the-strange-case-of-error-quot-unable-to-register-dll-ocx-regsvr32-failed-with-exit-code-0x5-quot.aspx#comments</comments><description>&lt;p&gt;In the past years, I have received some bug reports (less than 10 out of dozens of thousands of installations) reporting that the setup of MZ-Tools 3.0 for VBA / VB6 was failing with this error:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;&amp;quot;Unable to register DLL/OCX:RegSvr32 failed with exit code 0x5&amp;quot;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;I never discovered the cause (I just recommended to reinstall Office or VB6, depending on the case, or I sent the list of dependencies), but in the last weeks the problem has happened to two users of Microsoft Office 2013 using a clean installation. I already suspected that the problem was related to the file MSADDNDR.DLL (in the folder C:\Program Files (x86)\Common Files\designer), the reference used by add-ins for VB6 and for the VBA editor. &lt;/p&gt;
&lt;p&gt;So I decided to investigate, and lo and behold, it happens that Office 2013 doesn&amp;#39;t install that file, it just installs the MSADDNDR.OLB object library file. I even used the orca.exe tool of the Microsoft Windows SDK to open the .msi files of the Office 2013 setup to verify. I guess that somehow some users of VB6 and old versions of Office had this file missing or damaged, what would explain the case completely.&lt;/p&gt;
&lt;p&gt;To fix the problem, the new setups of MZ-Tools 3.0 released today install this file:&lt;/p&gt;
&lt;p&gt;MZ-Tools 3.0.1206 for VBA with bug fix to support Microsoft Office 2013&lt;br /&gt;&lt;a href="http://www.mztools.com/blog/mz-tools-3-0-1206-for-vba-with-bug-fix-to-support-microsoft-office-2013/"&gt;http://www.mztools.com/blog/mz-tools-3-0-1206-for-vba-with-bug-fix-to-support-microsoft-office-2013/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1819068" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/carlosq/archive/tags/The+strange+case+of_2E00__2E00__2E00_/default.aspx">The strange case of...</category></item><item><title>Red Gate Blog Guest post: Using .NET Reflector to understand and debug Visual Studio assemblies</title><link>http://msmvps.com/blogs/carlosq/archive/2012/10/31/red-gate-blog-guest-post-using-net-reflector-to-understand-and-debug-visual-studio-assemblies.aspx</link><pubDate>Tue, 30 Oct 2012 22:36:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1818646</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2012/10/31/red-gate-blog-guest-post-using-net-reflector-to-understand-and-debug-visual-studio-assemblies.aspx#comments</comments><description>&lt;p&gt;After I wrote this &lt;a href="http://msmvps.com/blogs/carlosq/archive/2012/09/27/mz-tools-articles-series-howto-debug-visual-studio-assemblies-with-net-reflector.aspx"&gt;post&lt;/a&gt; about using&lt;span id="yui-gen13" class="share-body"&gt; &lt;/span&gt; &lt;a href="http://www.reflector.net/"&gt;.NET Reflector&lt;/a&gt; to debug Visual Studio assemblies, &lt;span id="yui-gen13" class="share-body"&gt;Red Gate&lt;/span&gt;&lt;span id="yui-gen13" class="share-body"&gt; asked me to
 write a guest post on their blog to tell more about it:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Guest post: Using .NET Reflector to understand and debug Visual Studio assemblies&lt;a href="http://www.reflector.net/2012/10/guerst-post-using-net-reflector-to-understand-and-debug-visual-studio-assemblies/"&gt;&lt;br /&gt;http://www.reflector.net/2012/10/guerst-post-using-net-reflector-to-understand-and-debug-visual-studio-assemblies/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1818646" width="1" height="1"&gt;</description></item><item><title>Adopting Visual Studio 2012</title><link>http://msmvps.com/blogs/carlosq/archive/2012/10/20/adopting-visual-studio-2012.aspx</link><pubDate>Sat, 20 Oct 2012 15:39:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1818247</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2012/10/20/adopting-visual-studio-2012.aspx#comments</comments><description>&lt;p&gt;Finally today, after much reluctance in the past weeks, I have decided to adopt Visual Studio 2012 as the development environment for all my Visual Studio solutions, and I have just migrated them. I still find the default Light theme unpalatable but the &lt;a href="http://visualstudiogallery.msdn.microsoft.com/366ad100-0003-4c9a-81a8-337d4e7ace05"&gt;Visual Studio 2012 Color Theme Editor extension&lt;/a&gt; provides much more pleasant themes and you can even switch themes with a couple of clicks.&lt;/p&gt;
&lt;p&gt;What prompted me to the move was that Packt Publishing gave me a copy of the book &lt;a href="http://www.richard-banks.org/2012/09/visual-studio-2012-cookbook-is-now.html"&gt;Visual Studio 2012 Cookbook of fellow MVP Richard Banks&lt;/a&gt; to write a review and after reading the first chapter about the new IDE enhancements in the Solution Explorer and Tab Well I realized they were too good to miss the opportunity to use them on a daily basis.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1818247" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/carlosq/archive/tags/VS+2012/default.aspx">VS 2012</category></item><item><title>MZ-Tools Articles Series: HOWTO: Get an inverted bitmap to use with the Dark theme of Visual Studio 2012 from an add-in.</title><link>http://msmvps.com/blogs/carlosq/archive/2012/10/14/mz-tools-articles-series-howto-get-an-inverted-bitmap-to-use-with-the-dark-theme-of-visual-studio-2012-from-an-add-in.aspx</link><pubDate>Sun, 14 Oct 2012 17:19:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1818057</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2012/10/14/mz-tools-articles-series-howto-get-an-inverted-bitmap-to-use-with-the-dark-theme-of-visual-studio-2012-from-an-add-in.aspx#comments</comments><description>&lt;p&gt;There is a feature in my &lt;a href="http://msmvps.com/controlpanel/blogs/posteditor.aspx/htt"&gt;MZ-Tools add-in&lt;/a&gt; that requires to show the pictures of its commands in a treeview, to select which ones to be visible or not. When using Visual Studio 2012 and the Dark theme, the background of the form and the treeview are darked, and the bitmaps should have inverted colors, as shown in this picture:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/carlosq/0675.VS2012InvertedBitmaps.jpg"&gt;&lt;img src="http://msmvps.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/carlosq/0675.VS2012InvertedBitmaps.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I wanted to reuse the command pictures and use a function that inverts their colors as VS 2012 does. I knew the &lt;a href="http://msdn.microsoft.com/en-us/library/jj159159.aspx"&gt;ThemeDIBits method of the IVsUIShell5 interface&lt;/a&gt;, but it took me a while to discover a Visual Studio assembly that used it. Finally I found it and here is the approach:&lt;/p&gt;
&lt;p&gt;HOWTO: Get an inverted bitmap to use with the Dark theme of Visual Studio 2012 from an add-in.&lt;br /&gt;&lt;a href="http://www.mztools.com/articles/2012/MZ2012030.aspx"&gt;http://www.mztools.com/articles/2012/MZ2012030.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The sample also shows how to get the background color of toolwindows, using also the IVSUIShell5 interface.&lt;/p&gt;
&lt;p&gt;Note: my command pictures use the almost green (RGB=0,254,0) to denote the transparent color, and the sample provided uses that color, but you can use any color.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1818057" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/carlosq/archive/tags/MZ-Tools+Articles+Series/default.aspx">MZ-Tools Articles Series</category><category domain="http://msmvps.com/blogs/carlosq/archive/tags/VS+2012/default.aspx">VS 2012</category></item><item><title>MZ-Tools Articles Series: HOWTO: Detect Visual Studio requirements for MSI-based extensions setups.</title><link>http://msmvps.com/blogs/carlosq/archive/2012/10/13/mz-tools-articles-series-howto-detect-visual-studio-requirements-for-msi-based-extensions-setups.aspx</link><pubDate>Sat, 13 Oct 2012 09:28:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1818022</guid><dc:creator>carlosq</dc:creator><slash:comments>0</slash:comments><comments>http://msmvps.com/blogs/carlosq/archive/2012/10/13/mz-tools-articles-series-howto-detect-visual-studio-requirements-for-msi-based-extensions-setups.aspx#comments</comments><description>&lt;p&gt;My new article in the &lt;a href="http://msmvps.com/blogs/carlosq/archive/tags/MZ-Tools+Articles+Series/default.aspx"&gt;MZ-Tools Articles Series&lt;/a&gt; is about Visual Studio extension setups (a digression from the &amp;quot;theming extensions&amp;quot; subject of my last articles). I learn something new very often from questions in the &lt;a href="http://social.msdn.microsoft.com/forums/en-US/vsx/threads/"&gt;MSDN Visual Studio Extensibility (VSX) Forum&lt;/a&gt;, when I have to investigate something before providing an answer. &lt;/p&gt;
&lt;p&gt;A few days ago a question led me to learn something new that I have documented here:&lt;/p&gt;
&lt;p&gt;HOWTO: Detect Visual Studio requirements for MSI-based extensions setups.&lt;br /&gt;&lt;a href="http://www.mztools.com/Articles/2012/MZ2012029.aspx"&gt;http://www.mztools.com/Articles/2012/MZ2012029.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;While writing that article I noticed that I had to update a bit these old ones:&lt;/p&gt;
&lt;p&gt;HOWTO: Detect installed Visual Studio editions, packages or service packs&lt;br /&gt;&lt;a href="http://www.mztools.com/Articles/2008/MZ2008003.aspx"&gt;http://www.mztools.com/Articles/2008/MZ2008003.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;HOWTO: Detect if Visual Studio .NET is installed in a Visual Studio Setup package for an add-in&lt;br /&gt;&lt;a href="http://www.mztools.com/Articles/2006/MZ2006001.aspx"&gt;http://www.mztools.com/Articles/2006/MZ2006001.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1818022" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/carlosq/archive/tags/MZ-Tools+Articles+Series/default.aspx">MZ-Tools Articles Series</category></item></channel></rss>