Unrecognized attribute ‘targetFramework’ error


Yesterday while publishing a WCF Service to IIS I got this error from the VS2010 auto generated web.config file.

<compilation debug="true" targetFramework="4.0">

After searching I found it is because of the Framework version setting in the Application Pool of the web application.

In IIS 7, you can modify the application pool by selecting the Application Pools node from left side bar, and Select the Basic Settings, which will bring the Edit Application Pool dialog, where you can choose the .Net Framework Version. To fix the issue, it should set to version 4.x

Edit Application Pool Dialog

Edit Application Pool Dialog

Anuraj is currently working as Technical Lead. He is a regular speaker on Technology events. He has more than 11+ years experience with Microsoft.Net Technologies.

Facebook Twitter LinkedIn Google+ 

  • Fred

    Good point, that works (as long as one has upgraded IIS with .net 4 and to do that, one will need to add roles / features with Server Manager if running win server 2008)

  • Brian

    The issue may also occur if the ASP.NET version is not properly registered. there is a blog post explaining the details here.