473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

C#/ASP.Net Codebehind type not found at run-time

Using VS 2003 and Cassini web server. I'm new to ASP.Net and so this may be a dumb
question.

I'm getting an error where the type 'FarmLand.WebForm1' is not found. The Codebehind
C# source file declares a namespace of FarmLand and a class of WebForm1.

Does one have to restrict which namespace one uses in Codebehind forms? Maybe match
the namespace the aspx file has?

When one adds a namespace then does one have to move the file to a subdirectory
(analogous to Java) and maybe that's why the class is not getting found?

Or is my error in some other direction?

Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service
this request. Please review the following specific parse error details and modify
your source file appropriately.

Parser Error Message: Could not load type 'FarmLand.WebForm1'.

Source Error:

Line 1: <%@ Page language="c#" Codebehind="DeviceUpdateStatus.aspx.cs"
AutoEventWireup="false" Inherits="FarmLand.WebForm1" %>
Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
Line 3: <HTML>
Source File: d:\mainpage\wwwroot\WebApplication1\DeviceUpdateSt atus.aspx Line: 1

Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032
<%@ Page language="c#" Codebehind="DeviceUpdateStatus.aspx.cs"
AutoEventWireup="false" Inherits="FarmLand.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Device Service Status</title>
<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">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
</form>

Hello world!

<!--StartFragment -->
<asp:label id="TestLabelInAsp"/>
<%# WriteSnippet(8) %>

</body>
</HTML>
using System.Web.UI.HtmlControls;

namespace FarmLand
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

//introduced syntax error here.

//TestLabelInAsp.Text = "<b>This comes from the Page_Load method in
DeviceUpdateStatus.aspx.cs";
}

public string WriteSnippet(int Iterations)
{
string OutputString;
OutputString = "";

for (int i=0; i <= Iterations; i++)
{
OutputString = OutputString + "<font size='"+i+"'>ASP.NET</font><br/>";
}
return OutputString;
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}
Nov 19 '05 #1
1 2504
Why you rename your codebehind file??
WebForm1.aspx
WebForm1.aspx.cs

may be this is the problem, I notice some problem when i rename my
codebehind Also.. but not "Not Found" error, there is a problem in your
webserver not in the page..
and you can name ure namespave whatever u want without thinking about folder
names at all..

"Randall Parker" <NOtechieSPAMpundit_please@future_avoidjunk_pundit .com>
wrote in message news:eh**************@TK2MSFTNGP09.phx.gbl...
Using VS 2003 and Cassini web server. I'm new to ASP.Net and so this may
be a dumb question.

I'm getting an error where the type 'FarmLand.WebForm1' is not found. The
Codebehind C# source file declares a namespace of FarmLand and a class of
WebForm1.

Does one have to restrict which namespace one uses in Codebehind forms?
Maybe match the namespace the aspx file has?

When one adds a namespace then does one have to move the file to a
subdirectory (analogous to Java) and maybe that's why the class is not
getting found?

Or is my error in some other direction?

Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required
to service this request. Please review the following specific parse error
details and modify your source file appropriately.

Parser Error Message: Could not load type 'FarmLand.WebForm1'.

Source Error:

Line 1: <%@ Page language="c#" Codebehind="DeviceUpdateStatus.aspx.cs"
AutoEventWireup="false" Inherits="FarmLand.WebForm1" %>
Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
Line 3: <HTML>
Source File: d:\mainpage\wwwroot\WebApplication1\DeviceUpdateSt atus.aspx
Line: 1

Version Information: Microsoft .NET Framework Version:1.1.4322.2032;
ASP.NET Version:1.1.4322.2032
<%@ Page language="c#" Codebehind="DeviceUpdateStatus.aspx.cs"
AutoEventWireup="false" Inherits="FarmLand.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Device Service Status</title>
<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">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
</form>

Hello world!

<!--StartFragment -->
<asp:label id="TestLabelInAsp"/>
<%# WriteSnippet(8) %>

</body>
</HTML>
using System.Web.UI.HtmlControls;

namespace FarmLand
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

//introduced syntax error here.

//TestLabelInAsp.Text = "<b>This comes from the Page_Load method
in DeviceUpdateStatus.aspx.cs";
}

public string WriteSnippet(int Iterations)
{
string OutputString;
OutputString = "";

for (int i=0; i <= Iterations; i++)
{
OutputString = OutputString + "<font
size='"+i+"'>ASP.NET</font><br/>";
}
return OutputString;
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Boban Dragojlovic | last post by:
I create a new webform (I always use codebehind), and I insert some server-side controls into the form (the ASPX) Later, I switch to codeview, and I notice that some (sometimes all) of the...
6
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
6
by: Nehal Shah | last post by:
I've read that in the Page Directive of an aspx page, changing the CodeBehind attribute to Src saves you from having to compile the page before refreshing. This is preferable in a large...
12
by: A.M | last post by:
Hi, Using VS.NET 2003, If i use SRC page attribute instead of CodeBehind, do i still have intelisence and generally IDE support for that? Thanks, Ali
1
by: Michael | last post by:
Hello, I'm trying to implement sample I found on page templates, so I do not have to maintain "<html><head>..." on all my documents. But don't let that confuse you, this is an inheritance...
4
by: Mat | last post by:
Hi, I am having a bit of a problem trying to access / set properties of a usercontrol from the parent codebehind. This is what I have so far.. simple.aspx <%@ Page...
0
by: M K | last post by:
Okay, here is my message: The base class includes the field 'Preview1', but its type (ICUser.uCtrlPreview) is not compatible with the type of control (ASP.previewImg_ascx). What I am trying to...
1
by: Jon | last post by:
hi, "The type or namespace of 'Repeater1' could not be found..." when I try and bind a repeater in the Page_Load event using Repeater1.DataSource = table etc. It's all basic stuff copied from...
1
by: BJ-Mac Donel | last post by:
Please find the below error! This occure when i upload to server, but in my local file working really great, But if i change codebehind to src it is working well, but i also have problem with my...
4
by: WT | last post by:
Hello, Is there a way to set autoeventwireup from codebehind selectively. I want to set it to false for all usercontrols in my application. Thanks for idea. CS
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.