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

R

Randall Parker

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\DeviceUpdateStatus.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
}
}
 
I

Islamegy®

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..
 

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

Top