views:

794

answers:

3

When I run a webapp from Visual Studio 2008 SP1 using the internal web server (not IIS) I receive the above mentioned error.

The full error (source file Default.aspx.cs):

Compiler Error Message: CS0433: The type 'WebApplication3.Site1' exists in both 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\App_Web_site1.master.cdcab7d2.muczzy9v.dll' and 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\assembly\dl3\44c3a3cf\80dd34ed_6968ca01\WebApplication3.DLL'

The preceding full warning:

Warning: CS0436: The type 'WebApplication3._Default' in 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\App_Web_default.aspx.cdcab7d2._tlkwdos.0.cs' conflicts with the imported type 'WebApplication3._Default' in 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\assembly\dl3\44c3a3cf\e096e61c_6568ca01\WebApplication3.DLL'. Using the type defined in 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\App_Web_default.aspx.cdcab7d2._tlkwdos.0.cs'.

Source of warning points to an intermediate file App_Web_default.aspx.cdcab7d2._tlkwdos.0.cs:

Line 162:    
Line 163:    [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 164:    public class default_aspx : global::WebApplication3._Default, System.Web.IHttpHandler {
Line 165:        
Line 166:        private static bool @__initialized;

and my question: where does this come from?

The webapp (not website!) has one Default.aspx and one Site1.Master, no dependencies. They're almost empty, with an asp:Label on the page. Previously, this webapp worked fine. When I remove any references in Default.aspx.cs to the master, all goes well. The master has some code only.

It's actually one of many little fire-and-forget test webapps, so I couldn't care less. But I hadn't seen this before and now I'm curious of what to do, other then copying code into a new project (cleaning solution doesn't help).

Note: I've read this post and some others, they don't apply.

+1  A: 

Shut down w3svc and delete everything from c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\

added

on Windows 7

c:\Users\{username}\AppData\Local\Temp\Temporary ASP.NET Files\root\

LymanZerga
Yeah, that'll probably work (see my own comment above), but I hoped for a tad more insight in where this came from and what to do to prevent it (or even, make it reproducible). I'm not against solving brute force, but before doing so, I like to understand what's going on.
Abel
This has happened to me in the past. I believe it's a problem with VS where it doesn't clean up after a debugging session or before starting a new one. Last time this happened to me was with VS2005 a couple of years back.
LymanZerga
Accepted this as answer because it is a solution. However, it does not explain "why". If I find a better solution or a and actual reason, I'll update Lyman's answer or add my own.
Abel
A: 

Removing the class files from the App_Code folder, and placing them directly under the website, solved this issue for me.

Naveen Q
I'm afraid that's not really an option. Placing the dlls directly under the root is considered by many a security risk (App_Code or bin are special and inaccessible through IIS/ASP.NET, while any dll in the root can simply be downloaded and .NET assemblies are easily disassembled).
Abel
A: 

This May Happens when Same class Name is specified in multiple .aspx.cs files for eg 2 pages are created with different file name but by mistake have same class Name.

public partial class Test1: System.Web.UI.Page

public partial class Test1: System.Web.UI.Page

while building the app gives a warning but the applicaiton Runs, but while publishing the application downt work.

Deepak
Tx for looking into this. But in the case of your example, you use `partial class`, which is actually a common way (the only way) to split one class over several files, in which case you *must* use the same name.
Abel