Re: How is it possible ...



I challenge you to consider what is going on and ask why would that type of
exception occur.

It appears that in your Page_Unload() you are attempting to do clean up.

Private Sub Page_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)
System.IO.File.Delete(myExportFile)
End Sub

The problem is that the Session item "exportbestand" appears to be
string.empty. Perhaps, the value was never properly set.

The only place I see that you are setting the Session item is in page_init()

Session("exportbestand") = CType _
(myExportOptions.DestinationOptions,
CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName

You should test to see if DiskFileName has value, and if not, then work
backwards to where it is set to determine if a value is being set there.


Next, consider why the page_unload is firing without first displaying your
report.

try something like this in you error handling routine:

Try
PrepareReport(myReport)
Catch ex As Exception
dim innerEx as Exception, sb as system.text.stringbuilder
sb = new system.text.stringbuilder

sb.append(ex.tostring)

innerEx = ex.innerexception

do while not innerEx is nothing
sb.append(vbcrlf)
sb.append(innerEx.tostring)
innerEx = innerEx.innerexception
loop

response.write(sb.tostring)
response.end

'exc = New ApplicationException("Unable to prepare report.", ex)
'Throw exc
End Try


"Alison Givens" <info@xxxxxxxxxxx> wrote in message
news:O0G6XiFOGHA.3576@xxxxxxxxxxxxxxxxxxxxxxx
Yepper, the web.config is case sensitive.
That solves that problem.
Next problem:
When I give in the parameters and go to the form that holds the report I
get this:

Value cannot be null. Parameter name: path
Description: An unhandled exception occurred during the execution of the
current web request.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: path

Source Error:


Line 84: Dim myExportFile As String =
CType(Session.Item("exportbestand"), String)
Line 85:
Line 86: System.IO.File.Delete(myExportFile)
Line 87: End Sub
Line 88:

I commented it, so I could at least try to go further.
Then when the form with the report loads, I get:
Unable to prepare report.

This comes out of this error handeling:
Try
PrepareReport(myReport)
Catch ex As Exception
Dim exc As ApplicationException
exc = New ApplicationException("Unable to prepare report.", ex)
Throw exc
End Try

To be accurate I will put the entire current code here:


Private Enum FileNameFormats
SessionID = 0
GUIDDashes = 1
GUIDNoDashes = 2
End Enum



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()
Dim myReport As RapportAIRCOStoringen
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions

Try

Try
PrepareReport(myReport)
Catch ex As Exception
Dim exc As System.ApplicationException
exc = New System.ApplicationException("Unable to prepare
report.", ex)
Throw exc
End Try

Try
'exporteren to pdf
myExportOptions =
GetExportOptions(FileNameFormats.GUIDNoDashes, CType(myReport,
CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
myReport.Export()

Catch ex As Exception
Dim exc As ApplicationException
exc = New ApplicationException("Unable to export report.",
ex)
Throw exc
End Try

crViewer.ReportSource = myReport

Session("exportbestand") =
CType(myExportOptions.DestinationOptions,
CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName

Catch err As Exception
Response.Write("<BR>")
Response.Write(err.Message.ToString)
End Try




End Sub

#End Region

#Region "Page Implementation"

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
End Sub

Private Sub Page_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Unload
'Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

'System.IO.File.Delete(myExportFile)
End Sub

#End Region

#Region "Report Setup"

Private Sub PrepareReport(ByVal myReport As
CrystalDecisions.CrystalReports.Engine.ReportDocument)

Dim paramFields As ParameterFields
Dim paramField As ParameterField

Const SessionExecption As String = "Unable to read session
objects."

Try

paramFields = New ParameterFields
Try
paramField = CreateParameter("FiliaalKeuze")

paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("Filiaal")))

'paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue2")))
Catch ex As Exception
Dim exc As ApplicationException
exc = New ApplicationException(SessionExecption, ex)
Throw exc
End Try

myReport.SetParameterValue("FiliaalKeuze", paramField)

Try
'Todo wrap in try
paramField = CreateParameter("Periode")

paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
GetSessionValue("EindPeriode")))
Catch ex As Exception
Dim exc As System.ApplicationException
exc = New System.ApplicationException(SessionExecption, ex)
Throw exc
End Try

myReport.SetParameterValue("Periode", paramField)

Catch ex As Exception

Dim exc As System.ApplicationException
exc = New System.ApplicationException("Unable to set
paramatervalue.", ex)
Throw exc

End Try


End Sub

Private Function CreateParameter(ByVal ParameterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.ParameterFieldName = ParameterName

Return paramField

End Function


Private Function GetSessionValue(ByVal KeyName As String) As Object
Try
Return Session.Item(KeyName)
Catch ex As Exception
Dim exc As ApplicationException
exc = New ApplicationException(String.Format("Unable to read
value from session:{0}", KeyName), ex)
Throw exc
End Try

End Function



Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
ParameterDiscreteValue

Dim paramDiscreteValue As ParameterDiscreteValue
paramDiscreteValue = New ParameterDiscreteValue
paramDiscreteValue = Value

Return paramDiscreteValue

End Function

Private Function CreateParameterRangeValue(ByVal StartRange As Object,
ByVal EndRange As Object) As ParameterRangeValue
Dim paramRangeValue As ParameterRangeValue

paramRangeValue = New ParameterRangeValue

paramRangeValue.StartValue = StartRange
paramRangeValue.EndValue = EndRange

Return paramRangeValue
End Function

#End Region

#Region "Report Export"

Private Function GetExportOptions(ByVal UniqueFormat As
FileNameFormats, ByVal ExportOptions As
CrystalDecisions.Shared.ExportOptions) As
CrystalDecisions.Shared.ExportOptions

Dim myExportFile As String
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions

Try

Select Case UniqueFormat
Case FileNameFormats.SessionID
myExportFile = Session.SessionID.ToString
Case FileNameFormats.GUIDDashes
myExportFile = System.Guid.NewGuid.ToString("D")
Case FileNameFormats.GUIDNoDashes
myExportFile = System.Guid.NewGuid.ToString("N")
End Select

myExportFile = System.IO.Path.Combine(GetExportRoot(True),
String.Format("PDF_{0}.pdf", myExportFile))
myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
myDiskFileDestinationOptions.DiskFileName = myExportFile

myExportOptions = ExportOptions

With myExportOptions
.DestinationOptions = myDiskFileDestinationOptions
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = .ExportFormatType.PortableDocFormat
End With

Catch ex As Exception

Dim exc As System.ApplicationException
exc = New System.ApplicationException("Unable to prepare export
options.", ex)
Throw exc

End Try

Return myExportOptions

End Function

Private Function GetExportRoot(ByVal FromApplication As Boolean) As
String

Dim strExportRoot As String

If FromApplication Then
Try
Application.Lock()
strExportRoot = Application("ReportExportRoot")
Catch ex As Exception
Dim exc As ApplicationException
exc = New ApplicationException("Unable to lock Web
Application for read.", ex)
Throw exc
Finally
Application.UnLock()
End Try
Else
strExportRoot = Session("ReportExportRoot")
End If

Return strExportRoot

End Function

#End Region

#Region "Navigation Implementation"

Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdPrint.Click

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"

Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

Response.WriteFile(myExportFile)
Response.Flush()
Response.Close()

System.IO.File.Delete(myExportFile)

End Sub

Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEerste.Click
crViewer.ShowFirstPage()
End Sub

Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdLaatste.Click
crViewer.ShowLastPage()
End Sub

Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTerug.Click
crViewer.ShowPreviousPage()
End Sub

Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdVerder.Click
crViewer.ShowNextPage()
End Sub

Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles drpZoom.SelectedIndexChanged
crViewer.Zoom(drpZoom.SelectedItem.Value)
End Sub

#End Region



.



Relevant Pages

  • Re: Unhandled exception on Windows98
    ... I installed framework 2 and windows installer 2 on the windows 98 ... Private Sub btnQuickQuoteOK_Click(ByVal sender As System.Object, ... exception is not handled. ... Dim caller As New AsyncMethodCaller(AddressOf ...
    (microsoft.public.dotnet.framework)
  • Re: How is it possible ...
    ... Dim exc As ApplicationException ... Private Sub Page_Init(ByVal sender As System.Object, ... Dim myReport As RapportAIRCOStoringen ... Dim paramField As ParameterField ...
    (microsoft.public.dotnet.languages.vb)
  • RE: Converting a Datarow() to a Datatable
    ... exception is caused in the following situation: ... I type a char in the derived combobox and the drop down list ... Dim binding As New BindingSource ... Private Sub MultiColumnCombo1_TextChanged(ByVal sender As Object, ...
    (microsoft.public.vsnet.general)
  • Unhandled exception on Windows98
    ... I installed framework 2 and windows installer 2 on the windows 98 ... Private Sub btnQuickQuoteOK_Click(ByVal sender As System.Object, ... exception is not handled. ... Dim caller As New AsyncMethodCaller(AddressOf ...
    (microsoft.public.dotnet.framework)
  • Re: How is it possible ...
    ... of inner exception stack trace --- at ... Dim myExportFile As String = CType, ... 'Throw exc ... Private Sub Page_Init(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.languages.vb)