Freigeben über


Visual Studio 11 Preview and .NET 4 Platform Update 1 Side by Side Bug

If you install the Visual Studio 11 Preview release on a machine that has .NET 4 Platform Update 1 installed you will find that projects targeting .NET 4 Platform Update 1 will fail to build properly.  The error you will get is

'System.Activities.XamlIntegration.ActivityXamlServices' does not contain a definition for 'InitializeComponent'

The bug has been fixed and will not be a problem in the Visual Studio 11 Beta release but until then you should not install the Visual Studio 11 Preview release on development machines where you need to build projects targeting .NET 4 Platform Update 1.

The Problem

The cause of the error is that the build targets file for .NET 4.5 is incorrectly imported when building projects targeting .NET Framework 4.0.1.  The file in question is Microsoft.Common.Targets.

This file is deployed with the .NET Framework so you will find it under

  • \Windows\Microsoft.NET\Framework\v4.0.30319
  • \Windows\Microsoft.NET\Framework64\v4.0.30319

The line that causes the problem is line 4914

<Import Project="$(MSBuildToolsPath)\Microsoft.WorkflowBuildExtensions.targets" Condition="('$(TargetFrameworkVersion)' != 'v2.0' and '$(TargetFrameworkVersion)' != 'v3.5' and '$(TargetFrameworkVersion)' != 'v4.0') and Exists('$(MSBuildToolsPath)\Microsoft.WorkflowBuildExtensions.targets')"/>

To Manually Fix It

Warning! If you screw up this file your projects won’t build. Be sure to make a backup.

  1. Backup Microsoft.Common.Targets
  2. Open the file
  3. Go to line 4914 (or search for WorkflowBuildExtensions)
  4. Add another condition for v4.0.1

<Import Project="$(MSBuildToolsPath)\Microsoft.WorkflowBuildExtensions.targets" Condition="('$(TargetFrameworkVersion)' != 'v2.0' and '$(TargetFrameworkVersion)' != 'v3.5' and '$(TargetFrameworkVersion)' != 'v4.0' and '$(TargetFrameworkVersion)' != 'v4.0.1' ) and Exists('$(MSBuildToolsPath)\Microsoft.WorkflowBuildExtensions.targets')"/>

If Visual Studio is running while you make this change you will need to restart Visual Studio.

Happy Coding!
Ron Jacobs
https://www.ronjacobs.com

Comments

  • Anonymous
    October 02, 2011
    What is  .NET Framework 4.0.1?

  • Anonymous
    October 02, 2011
    @Mike - That is the version of .NET Framework 4 Platform Update 1

  • Anonymous
    October 05, 2011
    This is exacly what i'm looking for.Great!Thanks! It's possible to have the description about another impacts of VS 2011 instalation. I think is very common install the latest version on Dev machines.