Error in Masterpage, namespace already exists
Asked Answered
L

3

11

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" %>
Loney answered 19/12, 2012 at 8:2 Comment(1)
Change your master page's name to something other than Project . as your project's name as well as you master page are name Project. It is creating conflictPepillo
A
2

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.

Adelina answered 19/12, 2012 at 8:7 Comment(3)
I get this error Error 3 The namespace '<global namespace>' already contains a definition for 'Project' C:\ProjectAsp\Project\Project.Master.cs 15 11 C:\ProjectAsp\Project\Loney
Did you try to change the namespace name just to see if the error change ?Adelina
Look at that thread #6062472Adelina
P
1

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.

Proterozoic answered 19/12, 2012 at 8:11 Comment(1)
Still an error Error 3 Could not load type 'Project'. C:\ProjectAsp\Project\Project.Master 3Loney
P
0

Change your master page's name to something other than Project . as your project's name as well as you master page are name Project. It is creating conflict.

Pepillo answered 19/12, 2012 at 9:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.