Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
System.NullReferenceException: Object reference not set to an instance of an object.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="PatricQ, post: 360948"] I use VS.NET and yes I'm a beginner in ASP.NET. Here is the problem: in "%webroot%\components" is the folowing vb code file: framework.vb ---------------------------------------- Imports System Imports System.Configuration Imports System.Web Imports System.Data Imports System.Collections Public Class framework Public framework_name As String = "Hello" Public framework_logo As String = "" End Class ---------------------------------------- Then in %webroot%\ is the main (test) page for the site: default.aspx.vb (code behind file): ---------------------------------------- Imports System.Web Imports AIS3 Public Class _default Inherits System.Web.UI.Page Protected label1 As System.Web.UI.WebControls.Label Protected maintitle As System.Web.UI.HtmlControls.HtmlGenericControl Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init Dim _framework As framework = CType(HttpContext.Current.Items("framework"), framework) label1.Text = _framework.framework_name maintitle.InnerText = "New title for page" End Sub End Class ---------------------------------------- There is no code in default.aspx and VS.NET creates the namespace "AIS3" automatically. I imported it in default.aspx.vb file but im not sure that was really needed. But... when i run the thing i get: --------------------------------------- Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 26: Dim _framework As framework = CType(HttpContext.Current.Items("framework"), framework) Line 27: Line 28: label1.Text = _framework.framework_name Line 29: Line 30: maintitle.InnerText = "New title for page" Source File: c:\inetpub\wwwroot\AIS3\default.aspx.vb Line: 28 Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] AIS3._default.Page_Init(Object sender, EventArgs e) in c:\inetpub\wwwroot\AIS3\default.aspx.vb:28 System.Web.UI.Control.OnInit(EventArgs e) +67 System.Web.UI.Control.InitRecursive(Control namingContainer) +241 System.Web.UI.Page.ProcessRequestMain() +174 ------------------------------------------ Line 28 is marked What am i doing wrong? Thanku :) Patrick [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
System.NullReferenceException: Object reference not set to an instance of an object.
Top