MSDN Community Content for “Automation and Extensibility for Visual Studio” updated for VS 2010

I mentioned in my last post that the MSDN documentation for Visual Studio uses a mechanism in the URL to reference several versions of Visual Studio. I noticed that the Community Content at the bottom of each documentation page doesn’t propagate from one documentation version to the next one, with good criteria I guess because maybe the content is not relevant in the next version. So, although long overdue too, I have entered today the community content for MSDN VS 2010 documentation that I entered in Sep 2008 for Visual Studio 2008 since all of it is relevant. It has been dozens of blocks with references to articles of the MZ-Tools Article Series.

MZ-Tools Resources about Visual Studio .NET extensibility updated for VS 2010

MSDN has a nice URL mechanism to reference several Visual Studio versions of the same documentation, for example:

Automation and Extensibility for Visual Studio (Visual Studio 2010)
http://msdn2.microsoft.com/en-us/library/xc52cke4(en-US,VS.100).aspx

Automation and Extensibility for Visual Studio (Visual Studio 2008)
http://msdn2.microsoft.com/en-us/library/xc52cke4(en-US,VS.90).aspx

Automation and Extensibility for Visual Studio (Visual Studio 2005)
http://msdn2.microsoft.com/en-us/library/xc52cke4(en-US,VS.80).aspx

Long overdue, but today I have updated the MZ-Tools Resources about Visual Studio .NET extensibility page with links to Visual Studio 2010 extensibility resources (downloads of SDKs, documentation, etc.).

Visual Studio 2010 Productivity Power Tools crashing when add-in calls Application.DoEvents

I had three bug reports from customers of my MZ-Tools add-in for Visual Studio 2010 with a “System.NullReferenceException: Object reference not set to an instance of an object.” that happened “when closing Visual Studio”. The stack trace is something like this:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.Text.Editor.Implementation.DefaultScrollMap.TranslatePosition(SnapshotPoint bufferPosition)
   at Microsoft.VisualStudio.Text.Editor.Implementation.DefaultScrollMap.GetCoordinateAtBufferPosition(SnapshotPoint bufferPosition)
   at Microsoft.PowerTools.OverviewMargin.Implementation.OverviewMargin.SimpleScrollBar.GetYCoordinateOfBufferPosition(SnapshotPoint bufferPosition)
   at Microsoft.PowerTools.CaretMargin.CaretMarginElement.InvalidateIfChanged(Boolean highlightsChanged)
   at Microsoft.PowerTools.CaretMargin.CaretMarginElement.<UpdateMarginMatches>b__1(Object )
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 uReason, Int32 pvLoopData)
   at System.Windows.Forms.ComponentManagerProxy.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.DoEvents()
   …

And indeed my add-in calls Application.DoEvents() in the event handler that sets to get notified when a solution is closed (that’s why the exception can happen “when closing Visual Studio”). I patched my add-in to ignore that exception, but the other day I got that exception too when calling DoEvents in other parts of the add-in, so it seems that any call to Application.DoEvents() can cause that exception in the Visual Studio 2010 Productivity Power Tools. I am using the latest version 10.0.20318.14 at the time of this writing.

Uninstalling Visual Studio 2010 SP1

Today finally I decided to uninstall SP1 of Visual Studio 2010. A sad decision, because I like to have the latest service packs and hotfixes, but my definition of service pack is something that fixes bugs, not introducing new ones, and SP1 introduces these two issues (a bug and a “by design” change actually) that I can’t stand anymore, and that are not going to be fixed:

VS 2010 SP1 breaks add-in debugging targetting .NET Framework 2.0 rather than .NET Framework
https://www.visualstudioextensibility.com/2011/03/15/vs-2010-sp1-breaks-add-in-debugging-targetting-net-framework-2-0-rather-than-net-framework

VS 2010 SP1 changing “ByVal” VB.NET code editor experience
https://www.visualstudioextensibility.com/2011/03/15/vs-2010-sp1-changing-quot-byval-quot-vb-net-code-editor-experience

I guessed that uninstalling SP1 from my laptop and my desktop computers was going to be long, and certainly it was so. Furthermore, it was annoying because the uninstaller asks for the original installation sources, even the installation source of Visual Studio 2010 Express Edition for one specific component (which I think never was installed on the computer that prompted for them, the other didn’t). Not only uninstalling SP1 is a long procedure (not unattended due to the source installation prompts) , but also you must reinstall or repair Visual Studio after uninstalling SP1. All of these are known issues described in the readme of Visual Studio 2010 SP1:

Visual Studio SP1 Readme:
http://go.microsoft.com/fwlink/?LinkId=210711

After a couple of (wasted) hours, I think that both Visual Studio 2010 installations are working again, without SP1.