on 06-06-2012 8:00 AM
Hello,
I have used Crystal Reports 11.5 in a Windows Service to send emails in a multi-threaded environment using VB.NET in .NET 4.0.
However, once in a while the ReportDocument.Close crashes the service with an AccessViolationException. Basically the service runs good for days, then crashes and might crash again five minutes later, or an hour later or even days later. I can't find a clear pattern.
At first different documents were emailed, closed and disposed simultaneously on different threads, so I thought multi-threading was the problem. I made some changes and the application is still threaded, but there is always one document loaded and disposed at any given time in the service (still on a worker thread though). But it still sometimes crashes on Close.
The code looks something like this...
InitReportDocument()
Using stream As Stream = _ReportDocument.ExportToStream(DirectCast(_AttachmentType, ExportFormatType))
stream.Position = 0
mailMessage.Attachments.Add(New Attachment(stream, _AttachmentName & "." & CrystalUtils.GetCrystalFormatExtension(_AttachmentType)))
smtpClient.Send(mailMessage)
End Using
smtpClient.Dispose
mailMessage.Dispose
_ReportDocument.Close ' Exception here
_ReportDocument.Dispose
_ReportDocument = Nothing
So this code works fine for 1000 emails, sometimes more, sometimes less, sometimes 100 and sometimes even less.
Some machine information:
OS: Windows Server Standard
Service Pack 2
Intel(R) Xeon(R) CPU E5630 @ 2.53Ghz 2.27 GHz (4 processors)
4,00 GB RAM
32 bits
Some information on the exception (from the Windows Event Log. Sorry, it's in Dutch):
Source: Application Error:
Toepassing met fout PrintServiceHost.exe, versie 1.0.0.0, tijdstempel 0x4fb12484, module met fout ntdll.dll, versie 6.0.6002.18327, tijdstempel 0x4cb73436, uitzonderingscode 0xc0000005, foutmarge 0x000665d6, proces-id 0x%9, starttijd van toepassing 0x%10.
Source: .NET Runtime
Toepassing: PrintServiceHost.exe
Framework-versie: v4.0.30319
Beschrijving: het proces is beëindigd als gevolg van een onverwerkte uitzondering.
Uitzonderingsinformatie: System.AccessViolationException
Stack:
bij CrystalDecisions.CrystalReports.Engine.CRPE.PECloseEngine()
bij CrystalDecisions.CrystalReports.Engine.CRPE.CloseCrpe()
bij CrystalDecisions.CrystalReports.Engine.ReportDocument.InternalClose(Boolean)
bij CrystalDecisions.CrystalReports.Engine.ReportDocument.Close()
/*** These are my own methods, they contain the code above. ***/
bij Modulo.CrystalLibrary.CrystalReport.CloseAndDispose()
bij Modulo.CrystalLibrary.CrystalReport.DoTask(Modulo.TaskEngine.ITaskIdentifier)
bij Modulo.TaskEngine.TaskQueue.DoTask(System.Threading.Tasks.Task)
/*** Ending of own methods, past here is the invoke of above method using a System.Threading.Tasks.Task ***/
bij System.Threading.Tasks.Task+<>c__DisplayClasse`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<ContinueWith>b__d()
bij System.Threading.Tasks.Task`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].InvokeFuture(System.Object)
bij System.Threading.Tasks.Task.InnerInvoke()
bij System.Threading.Tasks.Task.Execute()
bij System.Threading.Tasks.Task.ExecutionContextCallback(System.Object)
bij System.Threading.ExecutionContext.runTryCode(System.Object)
bij System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
bij System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
bij System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
bij System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
bij System.Threading.Tasks.Task.ExecuteEntry(Boolean)
bij System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
bij System.Threading.ThreadPoolWorkQueue.Dispatch()
bij System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Any idea's on what might be wrong and how I could fix it? This has been going on for a while and I'm just all out of idea's...
Thanks.
Hi Modulo,
There is a CR.NET space that you may want to post this question to. Here is the link to that space: http://scn.sap.com/community/crystal-reports-for-visual-studio
Hope that helps you get some answers!
Kristen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.