In a MVC2 project I moved a file from App_code to Content folder and compiled it. Then move it back again to App_Code and then changed its Build Action to \"Compile\". Now I
I had the same problem in one of my projects. Turns out the problem started from me coping a Master page.
The problem will also occur if two pages "Inherit" the same page.
I had the following line of code at the top of my "LoginMaster.Master" & "MasterPage.Master"
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MainMaster.master.cs" Inherits="Master_Pages_Header" %>
I changed the Inherits on my "LoginMaster.Master to:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="LoginMaster.master.cs" Inherits="Master_Pages_LoginMaster" %>
I was immediately able to publish my project with out any problems. Hopefully this works for someone else. I apologize for not use the correct terms.
You will also need to change the class in the .cs to match the Inherits name. If you don't it will cause an error.
IE:
public partial class Master_Pages_LoginMaster : System.Web.UI.MasterPage