469,342 Members | 5,647 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

Object Reference not set

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
Jul 19 '05 #1
2 10076
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
.

Jul 19 '05 #2


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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Chris S. | last post: by
28 posts views Thread by Daniel | last post: by
29 posts views Thread by web1110 | last post: by
5 posts views Thread by Michael Moreno | last post: by
16 posts views Thread by anonymous.user0 | last post: by
275 posts views Thread by Astley Le Jasper | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.