The Test Container for User Control Libraries in Visual Studio 2005 is awesome!  However, I noticed that when Visual Studio 2003 class library projects are converted up to 2005, they do not automatically get this debugging functionality when they contain user controls.

After digging around in the VS program files directory I came across the Windows Control Library project template.  It can be found at Microsoft Visual Studio 8\Common7\IDE\ProjectTemplates\CSharp\Windows\1033\WindowsControlLibrary.zip.

Within the item group for the source files to compile (see below) I noticed that there is a service element.  It turns out that that the service with guid 94E38DFF-614B-4cbd-B67C-F211BB35CE8B is the service for the Test Container.  Adding the service XML element within the compilation section of your .csproj file will change it from a plain-old class library to a Windows User Control Library.  Now when the project is debugged through Visual Studio the Test Container pops up.
 
Example .csproj compilation XML:

<ItemGroup>
  <Compile Include="UserControl1.cs">
   <SubType>UserControl</SubType>
  </Compile>
  <Compile Include="UserControl1.Designer.cs">
   <DependentUpon>UserControl1.cs</DependentUpon>
  </Compile>
  <Compile Include="Properties\AssemblyInfo.cs" />
  <Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
 </ItemGroup>

 


Comments are closed

James Nies

.NET Ramblings and Visual Studio Adventures