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.

Published Wednesday, April 27, 2005 3:15 PM by Jamie Cansdale

Comments

# re: Beta2 Breaks 'Test With... Debugger' (in VS2003)

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

Wednesday, April 27, 2005 1:43 PM by Mike Scott

# re: Beta2 Breaks 'Test With... Debugger' (in VS2003)

The problems you write about here can be fixed with a few small changes, and some are bugs that we know about but fixed after Beta 2 was shipped.

The first one is referencing the PIA. You can make a reference to the PIA that shipped with VS 2003, and because we have a binding redirect in place in 2005, when you use types from 2003 they should automatically redirect to 2005. We have also made a change to 2005 so that we build the EnvDTE PIA using the older version of the tool set (2003 tools) so that you can use the 2005 PIA in 2003. Unfortunately, this was not fully tested before we shipped the beta, and so you run into the IConnectionPoint<->UCOMIConnectionPoint problem. We fixed this in the final version of VS about 2 days after we forked the source tree for Beta 2. The way we handle this is to export the IA using ILDasm, we then run a Perl script over the code to change UCOMIConnectionPoint to IConnectionPoint, then we rebuild using the 2003 tools.

Second, there should not be any differences between using Commands.AddNamedCommand between VS 2003 and 2005 Beta 2. We added a new way, Commands2.AddNamedCommand2, but the old way will still work. AddNamedCommand2 allows you to create UI elements other than buttons (combo-boxes, etc), but those different UI elements do not work as they should in Beta 2 (they were fixed just yesterday). While you can use AddNamedCommand in both versions, you can use AddNamedCommand2 if you detect that you are running in 2005.

If you have any comments, problems, or suggestions, feel free to send me mail

Craig
craigs@microsoft.com

Wednesday, April 27, 2005 3:32 PM by Craig Skibo

# Fixes it

Your advice fixes it for me.

Thanks very much!

Rik

Wednesday, April 27, 2005 4:40 PM by Rik Hemsley

# re: Beta2 Breaks 'Test With... Debugger' (in VS2003)

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.

Thursday, April 28, 2005 1:51 PM by Chris Bernholt

# re: Beta2 Breaks 'Test With... Debugger' (in VS2003)

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.

Thursday, April 28, 2005 2:16 PM by Chris Bernholt

# re: Beta2 Breaks 'Test With... Debugger' (in VS2003)

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!

:)

Thursday, April 28, 2005 10:30 PM by eAndy

# 'Test With... Debugger' - Fixed!

Saturday, April 30, 2005 5:53 AM by TrackBack

# re: Beta2 Breaks 'Test With... Debugger' (in VS2003)

WORKED LIKE A CHARM. Thanks a lot...

Friday, May 20, 2005 4:27 PM by Blake Theiss

Leave a Comment

(required) 
(required) 
(optional)
(required)