I have a wcf service hosted in a website in IIS and I seem to have this issue. In my web.config I have this:
Solution: It seems that the web config should be:
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
I had the same error but my web app was running on framework v2.0. Changed my application pool from v2.0 to v4.0. all working...happy days
Another thing to check is is your .csproj file, specifically these items:
<TargetFrameworkProfile>Profile47</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
If you don't have a folder for the Profile indicated, you might need to manually change it to one you do have. You might also be able to download the target from https://www.microsoft.com/net/download/visual-studio-sdks.
Unfortunately, my colleague had this happen with an old-style PCL project (profile-based PCL), so he wasn't able to go download the .NET Portable target, but I had to give him the DLLs out of my functioning folder (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile47).
Deleting the hidden .vs folder and restarting Visual Studio fixed it for me.