Microsoft KB Archive/833268

= You receive a &quot;Compiler Error Message: CS1595&quot; error message when you use the Src attribute in an ASP.NET application =

Article ID: 833268

Article Last Modified on 4/29/2007

-

APPLIES TO


 * Microsoft ASP.NET 1.1
 * Microsoft ASP.NET 1.0
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition

-



SYMPTOMS
When you compile your Microsoft ASP.NET application in Microsoft Visual Studio .NET and then you try to apply the Compile on Demand approach by using the Src attribute to reference the code-behind class file, you receive the following compiler error message when you view the Web page in the ASP.NET application in your Web browser:

Compiler Error Message: CS1595: 'MyWebApp.WebForm1' is defined in multiple places; using definition from '%windir%:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\mywebapp\877759ce\3fb79741\assembly\dl2\6a29f2d8\00f82a8d_5c32c401\MyWebApp.DLL'

Note  is a placeholder for the name of your project.



CAUSE
When you compile your ASP.NET application by using Visual Studio .NET, the code-behind file is compiled and the  .dll file is created in the Bin folder. However, when you use the Src attribute, the code-behind file is again compiled on demand or Just In Time (JIT)-compiled. This behavior creates two assemblies with the same type definition. Therefore, you receive the compiler error message that is mentioned in the &quot;Symptoms&quot; section.



RESOLUTION
To resolve this problem, you must delete the Global.asax file and the MyWebApp.dll file from your project, and then open the page in Microsoft Internet Explorer. To do this, follow these steps:
 * 1) In Visual Studio .NET, click Show All Files on the Project menu.
 * 2) In Solution Explorer, expand bin. Right-click MyWebApp.dll, and then click Delete.
 * 3) In the Microsoft Development Environment dialog box, click OK.
 * 4) In Solution Explorer, right-click Global.asax, and then click Delete.
 * 5) In the Microsoft Development Environment dialog box, click OK.
 * 6) On the File menu, click Save All to save the Web Form and other associated project files.
 * 7) Start Internet Explorer.
 * 8) In the Address box, type http:// /MyWebApp/WebForm1.aspx, and then press ENTER. The WebForm1.aspx page opens.



STATUS
This behavior is by design.



Steps to reproduce the behavior
 Start Visual Studio .NET. On the File menu, point to New, and then click Project. The New Project dialog box appears. Under Project Types, click Visual C# Projects, and under Templates, click ASP.NET Web Application. In the Location box, type http:// /MyWebApp, and then click OK. By default, a form that is named WebForm1 form is created. Add a Literal control to the WebForm1 form. In Solution Explorer, right-click WebForm1.aspx, and then click View Code.</li>  Add the following code to the Page_Load procedure: Literal1.Text = &quot;This is a test page&quot;; </li> On the Build menu, click Build Solution.</li> On the Debug menu, click Start. The WebForm1.aspx page appears.</li> Close the WebForm1.aspx page.</li> In Solution Explorer, right-click WebForm1.aspx, and then click View Designer.</li> Switch to the HTML view of the WebForm1 form.</li>  In the HTML view of the WebForm1 form, locate the following code: <%@ Page language=&quot;c#&quot; Codebehind=&quot;WebForm1.aspx.cs&quot; AutoEventWireup=&quot;false&quot; Inherits=&quot;MyWebApp.WebForm1&quot; %> </li>  Replace the code that was located in step 13 with the following code: <%@ Page language=&quot;c#&quot; Src=&quot;WebForm1.aspx.cs&quot; AutoEventWireup=&quot;false&quot; Inherits=&quot;MyWebApp.WebForm1&quot; %> </li> On the Build menu, click Build Solution.</li> On the Debug menu, click Start. You receive the error that is mentioned in the &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">