Logo
BUG: Infinite recursion in add-in causes Visual Studio crash.

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Visual Studio 2005
Date: March 2009   Microsoft Visual Studio 2008
       
Introduction

When an add-in enters in an infinite recursion, it crashes Visual Studio.

Cause

This is a bug introduced in Visual Studio 2005. It didn't happen in Visual Studio .NET 2003 (in this IDE the exception was intercepted by Visual Studio and shown in a friendly message box without crashing).

More Information

Steps to reproduce the problem:

  • Create a Visual Studio 2005/2008 add-in with this code and load it:
Language: VB.NET   Copy Code Copy Code (IE only)
Public Class Connect
   Implements IDTExtensibility2

   Public Sub OnConnection(ByVal application As Object, ByVal connectMode As ext_ConnectMode, _
      ByVal addInInst As Object, ByRef custom As Array) Implements IDTExtensibility2.OnConnection

      Call f1()

   End Sub

   Private Sub f1()

      Call f1()

   End Sub

   Public Sub OnDisconnection(ByVal disconnectMode As ext_DisconnectMode, ByRef custom As Array) _
      Implements IDTExtensibility2.OnDisconnection
   End Sub

   Public Sub OnAddInsUpdate(ByRef custom As Array) Implements IDTExtensibility2.OnAddInsUpdate
   End Sub

   Public Sub OnStartupComplete(ByRef custom As Array) Implements IDTExtensibility2.OnStartupComplete
   End Sub

   Public Sub OnBeginShutdown(ByRef custom As Array) Implements IDTExtensibility2.OnBeginShutdown
   End Sub

End Class
Language: C#   Copy Code Copy Code (IE only)
public class Connect : IDTExtensibility2
{
   public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
   {
      f1();
   }

   private void f1()
   {
      f1();
   }

   public void OnDisconnection(ext_DisconnectMode disconnectMode, ref Array custom)
   {
   }

   public void OnAddInsUpdate(ref Array custom)
   {
   }

   public void OnStartupComplete(ref Array custom)
   {
   }

   public void OnBeginShutdown(ref Array custom)
   {
   }
}


Go to the 'Visual Studio Extensibility (VSX)' web site for more articles like this (Articles section)


Top