Beta2 Breaks 'Test With... Debugger' (in VS2003)

I have finally got the the bottom of the issue mentioned yesterday.  I can confirm that installing VS2005 beta2 or any of the Express products will break 'Test With... Debugger' in VS2003 (or VS2002).  What makes the situation worse it that uninstalling them won't fix the issue!  The good news is that I now have a patch that seems to work.  I'll explain what causes the issue and how the patch works.

To write an add-in that works with both VS2003 and VS2005, the first step is to start compiling against the new Visual Studio interop assembly (EnvDTE, Version 8.0.0.0).  Once you've done this you can detect which version your add-in is running under and register your command bar buttons in the appropriate way (this now differs between VS2002/3 and VS2005).  In theory the new version of EnvDTE.dll is backwards compatable with the old version (Version 7.0.3300.0). This was the case with Beta1 and TestDriven.NET worked fine with VS2003 and VS2005 installed. In Beta2 the EnvDTE (Version 8.0.0.0) assembly has changed and intruduced a new issue.

If you look at the new EnvDTE (Version 8.0.0.0, FileVersion 8.0.50215.44) inside .NET Reflector and 'View Imports' for the 'mscorlib' assembly, you will see the following: 

You can see that Reflector can't resolve the reference to 'IConnectionPoint'!  That is because 'IConnectionPoint' is a new interface in .NET Framework 2.0. This interface is used whenever an add-in registers a COM event listener. In the case of TestDriven.NET, it attempts to register an OnEnterDesignMode listener when 'TestWith... Debugger' is used.  Unfortunately this is now greeted with:

System.TypeLoadException: Could not load type System.Runtime.InteropServices.ComTypes.IConnectionPointContainer from assembly mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.

The workaround here is to force VS2003 to use the original EnvDTE (Version 7.0.3300.0). To do this you need to add a bindingRedirect to VS2003's application config file (probably located at %ProgramFiles%\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe.config). Add the following element underneith the last 'dependentAssembly':

<dependentAssembly>
    <assemblyIdentity name="EnvDTE" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="8.0.0.0" newVersion="7.0.3300.0"/>
</dependentAssembly>

Once you've done this, your VS2003 add-ins should start behaving themselves again. Please comment here and let me know how you get on.  I'd be interested to know what other add-ins this issue is affecting.

Update: It seems 'Test With... Debugger' is no longer very stable in VS2005 beta2.  I'm currently investagating.

Update: Mike Scott, could you try checking the box on the left hand side of TestDriven.NET in the 'Add-in Manager' (on the 'Tools' menu).  If this doesn't fix it, could you try doing that again but with Sysinternals DebugView running in the background.  See if there are any juicy looking exceptions.

6 Comments

  • The binding redirect made things worse. After adding it, there were no TestDriven.NET entries on any of the VS context menus at all! :-(

  • Your advice fixes it for me.



    Thanks very much!



    Rik

  • Same experience here on the redirect. The TestDriven.NET entries disappear completely. I noticed that the version of evndte.dll that is installed for VS 2003 on my machine isn't 7.0.3300.0 that you have in the redirect. Instead it is version 7.0.9466.0. I tried redirecting to that version and the TestDriven add-in won't even load. I'm running SP1 on the 1.1. framework along with having installed Beta 2 of Visual Studio.

  • Disregard the version, the file system says it is 7.0.9466.0, but the assembly shows 7.0.3300.0 when viewed in reflector or ildasm.

  • Adding the dependentAssembly to the config as detailed above makes it work in VS.net 2k3 which is where I wanted/needed it to work.



    thanks so much, I was lost without it!



    :)

  • WORKED LIKE A CHARM. Thanks a lot...

Comments have been disabled for this content.