multiple class instances

D

david

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>



any help would be appreiciated...
 
S

Scott M.

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?
 
M

morganm1

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
*This message indicates that you have duplicate class names withi
the same
namespace. Are you sure there is not another .cs file in you
project with
the same class name?


-
morganm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top