Visual Studio 2010 – .NET Framework 3.5 Target Error and Fix

Suppose you have an existing ASP.NET 4.0 C# application and for whatever reason you need to re-target it to ASP.NET 3.5 C#, you will likely encounter the following error when you do the Build -> Publish deployment.

 warning MSB3267: The primary reference
 "Microsoft.CSharp", which is a framework
 assembly, could not be resolved in the
 currently targeted framework.
 ".NETFramework,Version=v3.5". To resolve
 this problem, either remove the reference
 "Microsoft.CSharp" or retarget your
 application to a framework version which
 contains "Microsoft.CSharp".

Here is how to fix this error.

  1. Go to the folder where your project resides.  (e.g. C:\prj\myapp)
  2. Look for the .csproj file.  (e.g. C:\prj\myapp\myapp\myapp.csproj)
  3. Edit this file in notepad.exe.
  4. Search for “Microsoft.CSharp”.
  5. Comment it out.
<!-- <Reference Include="Microsoft.CSharp" /> -->

Now you should be able to build and publish your project.

Post a comment if you had encountered this problem and this tip resolved it for you.

Published in: on April 27, 2011 at 5:31 pm  Comments Off on Visual Studio 2010 – .NET Framework 3.5 Target Error and Fix  
%d bloggers like this: