Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2008 水晶报告PDF格式“;对象未设置为对象的实例;错误_Visual Studio 2008_Crystal Reports - Fatal编程技术网

Visual studio 2008 水晶报告PDF格式“;对象未设置为对象的实例;错误

Visual studio 2008 水晶报告PDF格式“;对象未设置为对象的实例;错误,visual-studio-2008,crystal-reports,Visual Studio 2008,Crystal Reports,早在我开始在这里工作之前,一位开发人员在VS2008中用VB.Net编写了一个web应用程序,其中包含一个链接,该链接使用Crystal Reports创建一个报告,作为PDF文件。用户向我报告链接生成错误。我不确定这是否一直是一个问题,现在才报告,或者服务器上是否有更改。这是一个应用程序,我很少参与,因为我一直在这里和开发谁写了它早就离开了公司。自90年代末以来,我就没有与Crystal Reports合作过。无论如何,这里有足够的背景是错误 我一直跟踪到objTemp.Export()方法调

早在我开始在这里工作之前,一位开发人员在VS2008中用VB.Net编写了一个web应用程序,其中包含一个链接,该链接使用Crystal Reports创建一个报告,作为PDF文件。用户向我报告链接生成错误。我不确定这是否一直是一个问题,现在才报告,或者服务器上是否有更改。这是一个应用程序,我很少参与,因为我一直在这里和开发谁写了它早就离开了公司。自90年代末以来,我就没有与Crystal Reports合作过。无论如何,这里有足够的背景是错误

我一直跟踪到objTemp.Export()方法调用(其中objTemp是Crystal Reports ReportClass的实例化)

当我在VisualStudioIDE中的机器上本地运行应用程序时,一切都完全按照它应该的方式工作。我重新编译并将应用程序发布到生产服务器上的一个单独文件夹中,然后运行我的版本,但仍然会收到与生产版本相同的错误

ASP错误页面如下所示:

“/MyApplication”应用程序中的服务器错误。

对象引用未设置为对象的实例。 描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源

异常详细信息:System.NullReferenceException:对象引用未设置为对象的实例

源错误:


版本信息:Microsoft.NET Framework版本:2.0.50727.3643;ASP.NET版本:2.0.50727.3634

我遇到的一个问题是,在错误中它指向“O:\MyApplication…”。这是我保存源代码的网络驱动器。没有映射到服务器的O:驱动器。这似乎是错误的根源,但我无法想象硬盘编码驱动器号会成为VisualStudio开发环境的标准部分。它从未在我编写/使用的任何其他应用程序中引发过此类问题



*增加了2013年3月19日,以响应Andrew的源代码请求
这是单击创建PDF文件的链接时调用的代码。

Private Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click Dim d Dim objViewReport As ViewReport = New ViewReport(frmView) dtReportComments = objViewReport.getDtReportComments Dim oRpt As Object If (objViewReport.intTimeOfDayID -1) Then oRpt = New rptTOC_DateSpecific() Else oRpt = New rptTOC_DateAll() End If oRpt.SetDataSource(dtReportComments) 'set Season, date and TimeOfDay Dim toSeason As CrystalDecisions.CrystalReports.Engine.TextObject = oRpt.ReportDefinition.ReportObjects.Item("txtSeason") Dim toTitle As CrystalDecisions.CrystalReports.Engine.TextObject = oRpt.ReportDefinition.ReportObjects.Item("txtViewReportDate") Dim toTimeOfDay As CrystalDecisions.CrystalReports.Engine.TextObject = oRpt.ReportDefinition.ReportObjects.Item("txtTimeOfDay") toSeason.Text = objViewReport.strSeasonID If (objViewReport.intTimeOfDayID -1) Then toTitle.Text = objViewReport.datViewReportDate.ToString("MM/dd/yyyy") toTimeOfDay.Text = objViewReport.strTimeOfDay Else toTitle.Text = "All" toTimeOfDay.Text = "All" End If ExportAndDisplayPDF(oRpt) End Sub 私有子btnPrint_Click(ByVal sender作为对象,ByVal e作为System.EventArgs)处理btnPrint。单击 暗淡的 Dim objViewReport As ViewReport=新ViewReport(frmView) dtReportComments=objViewReport.getDtReportComments 作为对象的弱oRpt 如果(objViewReport.intTimeOfDayID-1),则 oRpt=新的RPTOC_日期特定() 其他的 oRpt=新的RPTOC_DateAll() 如果结束 oRpt.SetDataSource(dtReportComments) '设置一天的季节、日期和时间 Dim toSeason As CrystalDecisions.CrystalReports.Engine.TextObject=oRpt.ReportDefinition.ReportObjects.Item(“TXTseasure”) Dim toTitle为CrystalDecisions.CrystalReports.Engine.TextObject=oRpt.ReportDefinition.ReportObjects.Item(“txtViewReportDate”) Dim toTimeOfDay作为CrystalDecisions.CrystalReports.Engine.TextObject=oRpt.ReportDefinition.ReportObjects.Item(“txtTimeOfDay”) toSeason.Text=objViewReport.strSeasonID 如果(objViewReport.intTimeOfDayID-1),则 toTitle.Text=objViewReport.datViewReportDate.ToString(“MM/dd/yyyy”) toTimeOfDay.Text=objViewReport.strTimeOfDay 其他的 toTitle.Text=“全部” toTimeOfDay.Text=“全部” 如果结束 导出和显示PDF(oRpt) 端接头
这是btnPrint\u click方法调用的代码


Public Function ExportAndDisplayPDF(ByVal objTemp As Object)
    Dim dNow As DateTime = Now

    Dim strFileName As String = dNow.Ticks & ".pdf"
    'write to a pdf file.
    Dim DiskOpts As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions()
    objTemp.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
    objTemp.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat

    DiskOpts.DiskFileName = HttpContext.Current.Request.PhysicalApplicationPath.ToString & "ReportOutput\" & strFileName

    objTemp.ExportOptions.DestinationOptions = DiskOpts
    Try
        objTemp.Export()
    Catch oRptExcept As Exception
        HttpContext.Current.Response.Write(oRptExcept.Message & "<br><br>" & oRptExcept.InnerException.Message)
    End Try
    HttpContext.Current.Response.Redirect("/MyApplication/aspx/print/Print.aspx?theDestination=" & strFileName)

End Function

公共函数ExportAndDisplayPDF(ByVal objTemp作为对象)
Dim dNow As DateTime=Now
Dim strFileName作为String=dNow.Ticks&“.pdf”
'写入pdf文件。
Dim DiskOpts As CrystalDecisions.Shared.DiskFileDestinationOptions=新建CrystalDecisions.Shared.DiskFileDestinationOptions()
objTemp.ExportOptions.ExportDestinationType=CrystalDecisions。[共享].ExportDestinationType.DiskFile
objTemp.ExportOptions.ExportFormatType=CrystalDecisions。[共享].ExportFormatType.PortableDocFormat
DiskOpts.DiskFileName=HttpContext.Current.Request.PhysicalApplicationPath.ToString&“ReportOutput\”和strFileName
objTemp.ExportOptions.DestinationOptions=DiskOpts
尝试
objTemp.Export()
捕获或接受为异常
HttpContext.Current.Response.Write(orptescept.Message&“

”&orptescept.InnerException.Message) 结束尝试 HttpContext.Current.Response.Redirect(“/MyApplication/aspx/print/print.aspx?theDestination=“&strFileName”) 端函数
只是在寻找解决方案。

谢谢

罗伯特

这个问题的答案与Crystal Reports完全无关。这就是当您发送一个程序员(me)来执行网络管理员工作时发生的情况。好吧,我知道,你们很多脑力劳动者都能做到,但我不是你们。我在社交方面几乎没有经验。刚好够过日子。虽然是我虚弱的大脑弄明白了

应用程序的工作方式是将数据读入表中,然后将数据发送到Crystal Reports对象,以保存为全新的PDF文件。然后在这之后,应用程序打开新的PDF文件进行查看。错误抱怨对象未实例化。对我来说,这就是编程问题

这根本不是一个编程问题。正在其中创建新PDF文件的文件夹没有网站运行所在用户组的写入权限


如果您没有写入权限,如何创建PDF?如果您没有写权限,如何创建PDF?

这是一个老问题,但我在过去几天遇到了类似的问题

通用的“未设置对象引用…”非常容易引起误解。 与往常一样,发布的代码在DEV和QA环境中可以正常工作,并且会失败 Private Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click Dim d Dim objViewReport As ViewReport = New ViewReport(frmView) dtReportComments = objViewReport.getDtReportComments Dim oRpt As Object If (objViewReport.intTimeOfDayID -1) Then oRpt = New rptTOC_DateSpecific() Else oRpt = New rptTOC_DateAll() End If oRpt.SetDataSource(dtReportComments) 'set Season, date and TimeOfDay Dim toSeason As CrystalDecisions.CrystalReports.Engine.TextObject = oRpt.ReportDefinition.ReportObjects.Item("txtSeason") Dim toTitle As CrystalDecisions.CrystalReports.Engine.TextObject = oRpt.ReportDefinition.ReportObjects.Item("txtViewReportDate") Dim toTimeOfDay As CrystalDecisions.CrystalReports.Engine.TextObject = oRpt.ReportDefinition.ReportObjects.Item("txtTimeOfDay") toSeason.Text = objViewReport.strSeasonID If (objViewReport.intTimeOfDayID -1) Then toTitle.Text = objViewReport.datViewReportDate.ToString("MM/dd/yyyy") toTimeOfDay.Text = objViewReport.strTimeOfDay Else toTitle.Text = "All" toTimeOfDay.Text = "All" End If ExportAndDisplayPDF(oRpt) End Sub

Public Function ExportAndDisplayPDF(ByVal objTemp As Object)
    Dim dNow As DateTime = Now

    Dim strFileName As String = dNow.Ticks & ".pdf"
    'write to a pdf file.
    Dim DiskOpts As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions()
    objTemp.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
    objTemp.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat

    DiskOpts.DiskFileName = HttpContext.Current.Request.PhysicalApplicationPath.ToString & "ReportOutput\" & strFileName

    objTemp.ExportOptions.DestinationOptions = DiskOpts
    Try
        objTemp.Export()
    Catch oRptExcept As Exception
        HttpContext.Current.Response.Write(oRptExcept.Message & "<br><br>" & oRptExcept.InnerException.Message)
    End Try
    HttpContext.Current.Response.Redirect("/MyApplication/aspx/print/Print.aspx?theDestination=" & strFileName)

End Function