The problem could be:
- the Application Pool for your site is configured for .NET Framework Version = v2.0.XXXXX
- .NET 4 isn’t installed on your server.
See also
- Unrecognized attribute ‘targetFramework’ …
- How to add ASP.NET 4.0 …
… which helped me fix a similar issue.