Object Reference not set

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pkpatel

    #1

    Object Reference not set

    Hi,

    I keep getting this error every time I try to load
    crystalreportvi ewer 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.NullRefe renceException: 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:


    [NullReferenceEx ception: Object reference not set to an
    instance of an object.]
    CrystalDecision s.Web..get_7( ) +189
    CrystalDecision s.Web.CrystalRe portViewer.OnIn it
    (EventArgs e) +352
    System.Web.UI.C ontrol.InitRecu rsive(Control
    namingContainer ) +235
    System.Web.UI.C ontrol.InitRecu rsive(Control
    namingContainer ) +179
    System.Web.UI.C ontrol.InitRecu rsive(Control
    namingContainer ) +179
    System.Web.UI.P age.ProcessRequ estMain() +171


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


    Imports System.Data
    Imports System.Data.Sql Client
    Imports CrystalDecision s.CrystalReport s.Engine


    Public Class view1
    Inherits System.Web.UI.P age
    Protected WithEvents CrystalReportVi ewer1 As
    CrystalDecision s.Web.CrystalRe portViewer
    Protected Const strConnection As String = _
    "driver={SQ L .....)"

    Private Sub Page_Load(ByVal sender As System.Object, ByVal
    e As System.EventArg s) 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(s trConnection)
    MyCommand.Conne ction = myConnection
    MyCommand.Comma ndText = "Select * from
    vwPayerSummary"
    MyCommand.Comma ndType = CommandType.Tex t
    myDA.SelectComm and = MyCommand

    myDA.Fill(myDS, "vwPayerSummary ")
    rpt.SetDataSour ce(myDS)
    CrystalReportVi ewer1.ReportSou rce = rpt

    Catch Excep As Exception
    'MessageBox.Sho w(Excep.Message , "Error",
    MessageBoxButto ns.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.NullRefe renceException: 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


  • AlexB

    #2
    Object Reference not set

    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.datas ource = myDS.Table1
    Datagrid1.Datab ind
    [color=blue]
    >-----Original Message-----
    >Hi,
    >
    >I keep getting this error every time I try to load
    >crystalreportv iewer on a webform with a dataset.
    >
    >Here is the error:
    >--------------------------------------------------------
    >Server Error in '/Cr_Dataset' Application.
    >----------------------------------------------------------[/color]
    -[color=blue]
    >---------------------
    >
    >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 [/color]
    where [color=blue]
    >it originated in the code.
    >
    >Exception Details: System.NullRefe renceException: 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:
    >
    >
    >[NullReferenceEx ception: Object reference not set to an
    >instance of an object.]
    > CrystalDecision s.Web..get_7( ) +189
    > CrystalDecision s.Web.CrystalRe portViewer.OnIn it
    >(EventArgs e) +352
    > System.Web.UI.C ontrol.InitRecu rsive(Control
    >namingContaine r) +235
    > System.Web.UI.C ontrol.InitRecu rsive(Control
    >namingContaine r) +179
    > System.Web.UI.C ontrol.InitRecu rsive(Control
    >namingContaine r) +179
    > System.Web.UI.P age.ProcessRequ estMain() +171
    >
    >
    >----------------------------------------------------------
    >Here is my code:
    >
    >
    >Imports System.Data
    >Imports System.Data.Sql Client
    >Imports CrystalDecision s.CrystalReport s.Engine
    >
    >
    >Public Class view1
    > Inherits System.Web.UI.P age
    > Protected WithEvents CrystalReportVi ewer1 As
    >CrystalDecisio ns.Web.CrystalR eportViewer
    > Protected Const strConnection As String = _
    > "driver={SQ L .....)"
    >
    >Private Sub Page_Load(ByVal sender As System.Object, [/color]
    ByVal [color=blue]
    >e As System.EventArg s) 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[/color]
    (strConnection)[color=blue]
    > MyCommand.Conne ction = myConnection
    > MyCommand.Comma ndText = "Select * from
    >vwPayerSummary "
    > MyCommand.Comma ndType = CommandType.Tex t
    > myDA.SelectComm and = MyCommand
    >
    > myDA.Fill(myDS, "vwPayerSummary ")
    > rpt.SetDataSour ce(myDS)
    > CrystalReportVi ewer1.ReportSou rce = rpt
    >
    > Catch Excep As Exception
    > 'MessageBox.Sho w(Excep.Message , "Error",
    >MessageBoxButt ons.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 [/color]
    where [color=blue]
    >it originated in the code.
    >
    >Exception Details: System.NullRefe renceException: Object
    >reference not set to an instance of an object.
    >RESOLUTION
    >A supported fix is now available from Microsoft, but it [/color]
    is [color=blue]
    >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 [/color]
    Support [color=blue]
    >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
    >
    >
    >.
    >[/color]

    Comment

    • Pranav Patel

      #3
      Re: Object Reference not set



      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!

      Comment

      Working...