Groups | Blog | Home
all groups > asp.net > november 2003 >

asp.net : multiple class instances


david
11/29/2003 8:17:32 PM
i am doing the walkthrough of an asp.net book and i have
come to one of the tutorials where i am supposed to
create a simple code behind method. but, when i follow
the instructions in the book i get this error message.
considering that i am following a walkthrough i would
like to iorn out this problem ASAP so i can continue...
here is the error message:

Compiler Error Message:
CS1595: 'Temperature.TemperatureCB' is defined in
multiple places; using definition
from 'C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705
\Temporary ASP.NET Files\mcsd\63097906\8e1380c7
\adecz8jd.dll'



and here is the simple code definition of the cs file:


//TemperatureCB.cs
//Define a namespace
namespace Temperature
{
//Define TemperatureCB class
public class TemperatureCB : System.Web.UI.Page
{
//Define ToCensius() method
double ToCelsius(double f)
{
//Calculate and return
return (5.0/9.0)*(f-32.0);
}

//Define the CreateTemperatureTable()
method
public void CreateTemperatureTable()
{
for (double f = 50.0; f<=100.0;
f++)
{
Response.Output.Write(
"<tr><td>{0}
</td><td>" +
"{1:f}</td><tr>",
f, ToCelsius(f));
}
}
}
}



and here is the asp file exactly as i have been running
it..




<! -- StepByStep1_7.aspx -->
<%@ Page Language="C#"
Inherits="Temperature.TemperatureCB"
Src="TemperatureCB.cs"%>
<html>
<body>
<h2>Fahrenheit to Celsius Conversion
Chart</h2>
<table border="2">
<tr>
<th>
&deg
Fahrenheit</th>
<th>
&deg Celsius</th>
</tr>
<%CreateTemperatureTable();%>
</table>
</body>
</html>



Scott M.
11/29/2003 11:32:41 PM
This message indicates that you have duplicate class names within the same
namespace. Are you sure there is not another .cs file in your project with
the same class name?


[quoted text, click to view]

morganm1
4/16/2004 4:53:48 PM

I think the problem is that the src attribute is set on the page *and
by default the BuildAction attribute of the code-behind file is set t
'compile' causing the file to be compiled twice, once by Visual Studi
and then again on the web server.

The Errata for the book says:
"In Step By Step 1.7, after step 3, access the Properties window fo
the TemperatureCB.cs file and change its Build Action property t
None."

The errata can be found here
http://www.techcontent.com/TG70315Errata.htm

[quoted text, click to view]


-
morganm
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message127281.htm
AddThis Social Bookmark Button