Object reference not set to an instance of an object.

G

Guest

I get the following error:

Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an
object.]
exception0905.Component1.FillDataSet(myDataSet1 dSet) +15
exception0905.WebForm1.Page_Load(Object sender, EventArgs e) +47
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

When trying to view a newly created webform that created using the
"Walkthrough: Creating a Web Application Using Visual C# or Visual Basic"
instructions.

Any idea why i get this error? I used different database and table than
provided in the walkthrough but followed everything so it should have worked.
New to .NET, suggestions needed. thx
 
G

Guest

Hi Paola,

Could you please post the code of the PageLoad handler?

This exceptions gets thrown when an object reference is not initialized. So
there should be some object in the PageLoad handler which you haven't defined
yet which causes the exception.
 
G

Guest

Thanks Rakesh for your assistance, below is the code:

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents MyDataSet11 As exception0905.myDataSet1
Protected myComponent As New Component1()

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.MyDataSet11 = New exception0905.myDataSet1
CType(Me.MyDataSet11,
System.ComponentModel.ISupportInitialize).BeginInit()
'
'MyDataSet11
'
Me.MyDataSet11.DataSetName = "myDataSet1"
Me.MyDataSet11.Locale = New System.Globalization.CultureInfo("en-US")
CType(Me.MyDataSet11,
System.ComponentModel.ISupportInitialize).EndInit()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
myComponent.FillDataSet(MyDataSet11)
DataGrid1.DataBind()
End If
' End of the new code.
End Sub

Rakesh Rajan said:
Hi Paola,

Could you please post the code of the PageLoad handler?

This exceptions gets thrown when an object reference is not initialized. So
there should be some object in the PageLoad handler which you haven't defined
yet which causes the exception.

--
HTH,
Rakesh Rajan
MVP, MCSD
http://www.msmvps.com/rakeshrajan/



Paola said:
I get the following error:

Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an
object.]
exception0905.Component1.FillDataSet(myDataSet1 dSet) +15
exception0905.WebForm1.Page_Load(Object sender, EventArgs e) +47
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

When trying to view a newly created webform that created using the
"Walkthrough: Creating a Web Application Using Visual C# or Visual Basic"
instructions.

Any idea why i get this error? I used different database and table than
provided in the walkthrough but followed everything so it should have worked.
New to .NET, suggestions needed. thx
 

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