Unrecognized attribute ‘targetFramework’ – Asp.Net 4.0

November 10th, 2009

I ran across this error after pushing out an upgraded .NET 4.0 MVC2 application to its existing IIS website.  After some digging around I found this document on MSDN: How to: Upgrade an ASP.NET Web Application to ASP.NET 4

Since the application was previously built on version 3.5, IIS was configured to run as Asp.Net 2.0. Well it turns out IIS runs under the new framework version 4.0. (not like 3.0, or 3.5 when the Application Pool runs as 2.0)

Kind of one those "I should have figured that out much quicker moments"… A simple change to the app pool to target 4.0, and were on our way.

  • http://bob-the-janitor.blogspot.com/ Bob The Janitor

    I was having this problem with a WCF service, to fix it I just removed the target framework from the web.config

  • http://elegantcode.com Jarod Ferguson

    if you removed it from the web.config and did not update the app pool, then chances are your WCF service is using 2.0 and targeting the incorrect http handler (svc-Integrated vs svc-Integrated-4.0). A symptom of this might be that is works in 2008, and not 2010 :)

  • http://bob-the-janitor.blogspot.com/ Bob The Janitor

    maybe, but that shouldn’t matter, I’m consuming a soap web service, it shouldn’t matter if it was 2.0, 3.5, 4.0 or even java for that matter. The whole point of web services are for interoperability

  • http://elegantcode.com Jarod Ferguson

    well, I think the point of the post is targeting .net 4.0 features. So, if you don’t want to take advantage of them, then yes, you can remove the attribute and run 3.5.

    There are quite a few improvements in the WCF service stack for 4.0, in which you can take advantage of if you run .net on both sides. (Especially for Silverlight, e.g DomainServce, Entity change tracking etc)

  • Roman Gherman

    I had the same problem but using VS’ virtual server not IIS.
    So here an article that could help you if you have the same problem:
    http://extremedev.blogspot.com/2011/10/migrating-wdproj-from-vs-2008-to-vs.html