Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in Masterpage, namespace already exists

I want to add some code into my masterpage. So I removed the namespace but when I want to test it it gives this error. No idea how to fix this.

Error 2 The namespace 'Project' in 'c:\Users\Test\AppData\Local\Temp\Temporary ASP.NET Files\project\fe95a550\6aff5a12\assembly\dl3\9f54421a\e011b011_23bccd01\Project.DLL' conflicts with the type 'Project' in 'c:\Users\Test\AppData\Local\Temp\Temporary ASP.NET Files\project\fe95a550\6aff5a12\App_Web_exfemb4u.dll' c:\Users\Test\AppData\Local\Temp\Temporary ASP.NET Files\project\fe95a550\6aff5a12\App_Web_hrdlxq5l.4.cs 154

Masterpage.cs

public partial class Project: System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
}

Masterpage

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Project.master.cs" Inherits="Project" %>
like image 965
Marnik Wouters Avatar asked Dec 19 '12 08:12

Marnik Wouters


2 Answers

Can you add a namespace before public partial ....

namespace Test
{
    public partial class MovieMeter : System.Web.UI.MasterPage
    {
         protected void Page_Load(object sender, EventArgs e)
         {
         }
    }
}

Why did you remove the namespace ? please add one.

like image 144
GeorgesD Avatar answered Oct 28 '22 00:10

GeorgesD


Replace:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Project.master.cs" Inherits="Project" %>

With:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Project.master.cs" Inherits="Project" %>

It might solve...

Then the reason for the error is due to the way these two attributes are handled:

CodeBehind: Needs to be compiled before being deployed and the compiled assembly is put in the bin folder of your website.

CodeFile: You deploy the source and it is compiled as it is needed. The compiled assembly is placed in the Temporary ASP.NET folder.

like image 28
Anujith Avatar answered Oct 28 '22 01:10

Anujith