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.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\ Microsoft.Common.targets(1360,9): 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.
- Go to the folder where your project resides. (e.g. C:\prj\myapp)
- Look for the .csproj file. (e.g. C:\prj\myapp\myapp\myapp.csproj)
- Edit this file in notepad.exe.
- Search for “Microsoft.CSharp”.
- 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.