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