Object Reference not set

P

Pkpatel

Hi,

I keep getting this error every time I try to load
crystalreportviewer on a webform with a dataset.

Here is the error:
--------------------------------------------------------
Server Error in '/Cr_Dataset' Application.
-----------------------------------------------------------
---------------------

Object reference not set to an instance of an object.
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:

An unhandled exception was generated during the execution
of the current web request. Information regarding the
origin and location of the exception can be identified
using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an
instance of an object.]
CrystalDecisions.Web..get_7() +189
CrystalDecisions.Web.CrystalReportViewer.OnInit
(EventArgs e) +352
System.Web.UI.Control.InitRecursive(Control
namingContainer) +235
System.Web.UI.Control.InitRecursive(Control
namingContainer) +179
System.Web.UI.Control.InitRecursive(Control
namingContainer) +179
System.Web.UI.Page.ProcessRequestMain() +171


----------------------------------------------------------
Here is my code:


Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine


Public Class view1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As
CrystalDecisions.Web.CrystalReportViewer
Protected Const strConnection As String = _
"driver={SQL .....)"

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
Dim rpt As New CrystalReport1() 'The report you
created.
Dim myConnection As SqlConnection
Dim MyCommand As New SqlCommand()
Dim myDA As New SqlDataAdapter()
Dim myDS As New Dataset1() 'The DataSet you
created.

Try

myConnection = New SqlConnection(strConnection)
MyCommand.Connection = myConnection
MyCommand.CommandText = "Select * from
vwPayerSummary"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand

myDA.Fill(myDS, "vwPayerSummary")
rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt

Catch Excep As Exception
'MessageBox.Show(Excep.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

End Class

Any help is appereciated.

Thanks

Pranav

This is what I found on your site

-----------------------------
FIX: Invalid Object in ASP Session State
The information in this article applies to:
· Microsoft Visual Studio .NET (2002), Professional
Edition
· Microsoft Visual Studio .NET (2002), Professional
Edition SP1
· Microsoft Visual Studio .NET (2002), Enterprise
Architect Edition
· Microsoft Visual Studio .NET (2002), Enterprise
Architect Edition SP1
· Microsoft Visual Studio .NET (2002), Enterprise
Developer Edition
· Microsoft Visual Studio .NET (2002), Enterprise
Developer Edition SP1
SYMPTOMS
A .NET-connected Web application stores an object in the
session state. When you leave the application idle for 12
to 20 minutes, and then try again to gain access to the
object, you may receive an invalid object exception error
message such as the following:
Server Error in '/TheTest Application' Application.

Object reference not set to an instance of an object.

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.
RESOLUTION
A supported fix is now available from Microsoft, but it is
only intended to correct the problem that is described in
this article. Apply it only to systems that are
experiencing this specific problem.

Note You must have a Visual Studio license agreement to
obtain this fix.

To resolve this problem, contact Microsoft Product Support
Services to obtain the fix. For a complete list of
Microsoft Product Support Services phone numbers and
information about support costs, visit the following
Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-
US;CNTACTMS
Note In special cases, charges that are ordinarily
incurred for support calls may be canceled if a Microsoft
Support Professional determines that a specific update
will resolve your problem. The usual support costs will
apply to additional support questions and issues that do
not qualify for the specific update in question.
Last Reviewed: 2/14/2003
Keywords: kbQFE kberrmsg kbfix kbBug KB810245
 
A

AlexB

I was doing virtually the same thing and my problem turned
out to be a permissions issue. I had to grant the aSPNET
account Full Access to the crystal directory as well as
the winnt\microsoft.net\framework\v1.x.xxxxx\ directory to
solve the problem. The error is pretty generic so you
could also have a data problem. You may want to verify
that the data is being retrieved by setting on the
datatables in the ds to a datagrid, e.g.

Datagrid1.datasource = myDS.Table1
Datagrid1.Databind
-----Original Message-----
Hi,

I keep getting this error every time I try to load
crystalreportviewer on a webform with a dataset.

Here is the error:
--------------------------------------------------------
Server Error in '/Cr_Dataset' Application.
---------------------------------------------------------- -
---------------------

Object reference not set to an instance of an object.
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:

An unhandled exception was generated during the execution
of the current web request. Information regarding the
origin and location of the exception can be identified
using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an
instance of an object.]
CrystalDecisions.Web..get_7() +189
CrystalDecisions.Web.CrystalReportViewer.OnInit
(EventArgs e) +352
System.Web.UI.Control.InitRecursive(Control
namingContainer) +235
System.Web.UI.Control.InitRecursive(Control
namingContainer) +179
System.Web.UI.Control.InitRecursive(Control
namingContainer) +179
System.Web.UI.Page.ProcessRequestMain() +171


----------------------------------------------------------
Here is my code:


Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine


Public Class view1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As
CrystalDecisions.Web.CrystalReportViewer
Protected Const strConnection As String = _
"driver={SQL .....)"

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
Dim rpt As New CrystalReport1() 'The report you
created.
Dim myConnection As SqlConnection
Dim MyCommand As New SqlCommand()
Dim myDA As New SqlDataAdapter()
Dim myDS As New Dataset1() 'The DataSet you
created.

Try

myConnection = New SqlConnection (strConnection)
MyCommand.Connection = myConnection
MyCommand.CommandText = "Select * from
vwPayerSummary"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand

myDA.Fill(myDS, "vwPayerSummary")
rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt

Catch Excep As Exception
'MessageBox.Show(Excep.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

End Class

Any help is appereciated.

Thanks

Pranav

This is what I found on your site

-----------------------------
FIX: Invalid Object in ASP Session State
The information in this article applies to:
· Microsoft Visual Studio .NET (2002), Professional
Edition
· Microsoft Visual Studio .NET (2002), Professional
Edition SP1
· Microsoft Visual Studio .NET (2002), Enterprise
Architect Edition
· Microsoft Visual Studio .NET (2002), Enterprise
Architect Edition SP1
· Microsoft Visual Studio .NET (2002), Enterprise
Developer Edition
· Microsoft Visual Studio .NET (2002), Enterprise
Developer Edition SP1
SYMPTOMS
A .NET-connected Web application stores an object in the
session state. When you leave the application idle for 12
to 20 minutes, and then try again to gain access to the
object, you may receive an invalid object exception error
message such as the following:
Server Error in '/TheTest Application' Application.

Object reference not set to an instance of an object.

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.
RESOLUTION
A supported fix is now available from Microsoft, but it is
only intended to correct the problem that is described in
this article. Apply it only to systems that are
experiencing this specific problem.

Note You must have a Visual Studio license agreement to
obtain this fix.

To resolve this problem, contact Microsoft Product Support
Services to obtain the fix. For a complete list of
Microsoft Product Support Services phone numbers and
information about support costs, visit the following
Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-
US;CNTACTMS
Note In special cases, charges that are ordinarily
incurred for support calls may be canceled if a Microsoft
Support Professional determines that a specific update
will resolve your problem. The usual support costs will
apply to additional support questions and issues that do
not qualify for the specific update in question.
Last Reviewed: 2/14/2003
Keywords: kbQFE kberrmsg kbfix kbBug KB810245


.
 
P

Pranav Patel

Hi Alex,

Thanks for your reply. I am new to .net. I am hoping that you have the
time to show me how and where to set the permissions. I get this error
even before the page loads.

Thanks again for your response.

Pkpatel
 

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