W
william.oram
I'll do my best to bring a rather complicated, multifile problem into
a single newsgroup question. It's a challenge to balance accuracy with
simple code that demonstrates the problem.
Assume an external .cs file containing a class MyClass:
namespace vortex
{
public class MyClass
{
public int number;
public MyClass(SqlDataReader r)
{
number = Convert.ToInt32(r["number"]);
}
}
}
Now consider an .aspx file with a chunk of C# in the head.
GetDetails() is a code-behind function that pulls data from SQL,
creates a new MyClass using a passed SqlDataReader, and returns the
new instance to 'details':
<HTML>
<HEAD>
<title>[ UT TeleCampus -- vorTex 2 ]</title>
<%
vortex.MyClass details = GetDetails();
details.number++; // (*)
%>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/
intellisense/ie5">
<LINK title="magicstyle" href="css/vortex.css" type="text/css"
rel="stylesheet">
<script type="text/javascript" src="includes/jsFunctions.js"></
script>
</HEAD>
(etc)
This works. But move the (*) line down like this, and I get the error
'The type or namespace name 'details' could not be found (are you
missing a using directive or an assembly reference?)'.
<HTML>
<HEAD>
<title>[ UT TeleCampus -- vorTex 2 ]</title>
<%
vortex.MyClass details = GetDetails();
%>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/
intellisense/ie5">
<LINK title="magicstyle" href="css/vortex.css" type="text/css"
rel="stylesheet">
<script type="text/javascript" src="includes/jsFunctions.js"></
script>
</HEAD>
(some HTML)
<div>
<%
details.number++; // (*)
%>
</div>
Another .aspx file in the same project does pretty much the same thing
with no complaints. I realise that it's treating 'details' as if it
were a namespace, but changing it to 'vortex.details.number++' doesn't
impact it any.
1) What can I do to fix this?
2) What could cause Visual Studio to treat this code properly in one
file and improperly in another?
Thanks!
a single newsgroup question. It's a challenge to balance accuracy with
simple code that demonstrates the problem.
Assume an external .cs file containing a class MyClass:
namespace vortex
{
public class MyClass
{
public int number;
public MyClass(SqlDataReader r)
{
number = Convert.ToInt32(r["number"]);
}
}
}
Now consider an .aspx file with a chunk of C# in the head.
GetDetails() is a code-behind function that pulls data from SQL,
creates a new MyClass using a passed SqlDataReader, and returns the
new instance to 'details':
<HTML>
<HEAD>
<title>[ UT TeleCampus -- vorTex 2 ]</title>
<%
vortex.MyClass details = GetDetails();
details.number++; // (*)
%>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/
intellisense/ie5">
<LINK title="magicstyle" href="css/vortex.css" type="text/css"
rel="stylesheet">
<script type="text/javascript" src="includes/jsFunctions.js"></
script>
</HEAD>
(etc)
This works. But move the (*) line down like this, and I get the error
'The type or namespace name 'details' could not be found (are you
missing a using directive or an assembly reference?)'.
<HTML>
<HEAD>
<title>[ UT TeleCampus -- vorTex 2 ]</title>
<%
vortex.MyClass details = GetDetails();
%>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/
intellisense/ie5">
<LINK title="magicstyle" href="css/vortex.css" type="text/css"
rel="stylesheet">
<script type="text/javascript" src="includes/jsFunctions.js"></
script>
</HEAD>
(some HTML)
<div>
<%
details.number++; // (*)
%>
</div>
Another .aspx file in the same project does pretty much the same thing
with no complaints. I realise that it's treating 'details' as if it
were a namespace, but changing it to 'vortex.details.number++' doesn't
impact it any.
1) What can I do to fix this?
2) What could cause Visual Studio to treat this code properly in one
file and improperly in another?
Thanks!