I have a .NET 3.5 (target framework) web application. I have some code that looks like this:
public string LogPath { get; private set; }
public string ErrorMsg
This error can also happen if you are using CodeFile="MyControl.ascx.cs" in your MyControl.ascx instead of CodeBehind="MyControl.ascx.cs".
In case of CodeFile, the 2.0 compiler tries to recompile the page, even if you have a WebProject instead of a WebSite and of course - does fail.
Changing the attribute name to CodeBehind fixed the problem in my case.