Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Randall Parker - 19 Oct 2005 03:39 GMT
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
    }
}
Islamegy® - 19 Oct 2005 10:10 GMT
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..

> Using VS 2003 and Cassini web server. I'm new to ASP.Net and so this may
> be a dumb question.
[quoted text clipped - 113 lines]
> }
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.