■開発環境
Windows7 SP1(x86)
Microsoft Visual Stdio 2008(ASP.net、VB 2008)
Crystal Report BASIC for Visual Stdio 2008
Microsoft .net compact FrameWork 2.0 SP2
Microsoft SQLserver 2008 R2
■本番環境
Windows server2008 R2 Standard(x64)
Crystal Report Basic Runtime for Visual Stdio 2008(x64)
IIS Ver7(ApplicationPool 32bitMode⇒False)
.net Framework 2.0
Microsoft SQLserver2008 R2(x64)
■症状
上記環境のWEBアプリでPDFの出力機能があるが、PDFが出力出来なくなる事がある。
この現象は複数のレポートで発生している。また、発生原因は不明だが今まで複数回発生している。
特に、アプリケーションの配置(入れ替え)を行った後に発生しやすい。(2回発生)
それ以外の通常実行中のタイミングでも発生している。(1回発生)
一旦PDFが出力不可となると、以下の状態となる。
・WEBアプリへ再ログインしてもPDFは出力出来ない
・IEを再起動してもPDFは出力出来ない
・他のユーザーもPDFの出力が出来ない
・他のPDFも出力出来ない
・他のマシンからもPDFの出力が出来ない
WEBアプリの他の機能(ExcelファイルのダウンロードやDBとのデータのやり取り等)は可能
症状が発生した時にIISでワーカープロセスの要求を確認すると
動詞:POST
状況:ExecuteRequestHandler
モジュール名:ManagedPipelineHandler
上記の状態の処理がPDFの作成をリクエストした回数分残っている。
この場合、PDFファイルの作成も行われていない。
ApplicationPoolのリサイクルを行う事でPDFが出力出来る様になる。
■コード
PDF作成処理
Public Function CreatePdf(ByVal rpt As String, ByVal dt As DataTable, Optional ByVal _pre As String = "", Optional ByVal params As String = "") As String
Dim Report As New CrystalReports.Engine.ReportDocument
Try
Dim crDfdOpt As New DiskFileDestinationOptions
Dim crExpOpt As New ExportOptions
Dim FileName As String = _pre & Now.ToString("yyyyMMddHHmmssfff") & ".pdf"
Report.Load(MapPath("~/Report/" & rpt))
Report.SetDataSource(dt)
crDfdOpt.DiskFileName = MapPath("~/PDF/" & FileName)
crExpOpt = Report.ExportOptions
crExpOpt.ExportDestinationOptions = crDfdOpt
crExpOpt.ExportDestinationType = ExportDestinationType.DiskFile
crExpOpt.ExportFormatType = ExportFormatType.PortableDocFormat
Report.Export()
Return FileName
Catch ex As Exception
Throw ex
Finally
Report.Close()
Report.Dispose()
End Try
End Function
-----------------------------------------------------------------------------------------------------------
上記処理で作成したファイルを以下のコードでWindow表示。
ClientScript.RegisterClientScriptBlock(Me.GetType(), "ReportWindow", "<script language=JavaScript>window.open('" & ret & "','_blank','lacation=0,resizable=1');</script>")
■知りたい事
①原因と対策
②原因と対策が不明な場合、何を調査すればよいか
以上。宜しくお願い致します。