Visual Studio Development Bookmark and Share   
 index > Crystal Reports for Visual Studio > CallbackOnCollectedDelegate was detected
 

CallbackOnCollectedDelegate was detected

hi, I am getting this error when generating pdf docs from crystal report app (C# 2.0).

CallbackOnCollectedDelegate was detected

Message: A callback was made on a garbage collected delegate of type 'CrystalDecisions.ReportAppServer.DataSetConversion!CrystalDecisions.ReportAppServer.DataSetConversion.DataSetConverter+CrdbAdoPlusDelegate::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.


I am creating pdf docs from crystal report app which is being hosted in console app. I have a report document with 6 sub reports. I am poppulating these sub reports on the report document by pushing a datatable/dataset. In doing that, I am instantiating report document once as a global variable. Then each next pdf doc will be using that same report document object but I am loading a new report doc every time new report(pdf doc) needs to be generated.

After about 20 to 30 docs are generated I get error listed on top "CallbackOnCollectedDelegate was detected" with detail description also provided earlier.

Reading this error made me think that if I put some kind of delay (1000 miliseconds) before loading report, it would help but did not solve my problem. It did went further than 20 to 30 docs to 104 docs but that error did come back.

I would appreciate if some one can shed some light



Thanks
Needy
Mahesh819  Monday, April 16, 2007 6:04 PM
Here's a similar thread I worked on. There's some evidence that this might be a bug in the MDA rather than the code it complains about. Your case is less compelling and there's no easy workaround. Turn off the MDA and test the heck out of it. Or contact Crystal Decisions for support...
nobugz  Tuesday, April 17, 2007 3:54 PM

I went to Debug-Exceptions-Managing Debugging Assistants

then de-selected "CallBackOnCollectedDelegate". Is this how MDA is turned off since I am getting error

CallbackOnCollectedDelegate was detected

Message: A callback was made on a garbage collected delegate of type 'CrystalDecisions.ReportAppServer.DataSetConversion!CrystalDecisions.ReportAppServer.DataSetConversion.DataSetConverter+CrdbAdoPlusDelegate::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.

Please advise

thanks

Mahesh819  Tuesday, April 17, 2007 6:08 PM
Looks like you got past this last problem judging from your other thread. The error code you're getting is bogus, calling Crystal Decisions support is warranted.
nobugz  Thursday, April 19, 2007 5:09 PM

I have not found the solution yet. If I putone secondof wait time before loading a new report document in to reportDocument object it goes on executes but if there is no wait then unfortunately I still get that error.

Please help me solve this. I tried turning off MDA and found out that it was

reportDocument.Subreports[summaryDocument].Database.Tables["command_1"].SetDataSource(headerData);//headerdata is a datatable

at line like this which would give me an exception stating no error and here is the stack trace

The thread 0x1318 has exited with code 0 (0x0).

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.CrystalReports.Engine.dll

System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>InvoicesHost.vshost.exe</AppDomain><Exception><ExceptionType>System.Runtime.InteropServices.COMException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>

No error.</Message><StackTrace> at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.ReplaceConnection(Object oldConnection, Object newConnection, Object parameterFields, Object crDBOptionUseDefault)

at CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val, Type type)

at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)

at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataTable dataTable)

at Invoices.InvoiceCreator.CreateInvoice(Int32 clientId, InvoiceType invoiceType, DateTime startDate, DateTime endDate) in C:\myfolder\Invoices\Invoices\InvoiceCreator.cs:line 254

at Invoices.InvoiceCreator.CreateOtherInvoices(DateTime startDate, DateTime endDate) in C:\myfolder\Invoices\Invoices\InvoiceCreator.cs:line 160

at Invoices.InvoiceCreator.CreateInvoices(DateTime invoiceDate) in C:\myfolder\Invoices\Invoices\InvoiceCreator.cs:line 63

at InvoicesHost.Program.Main(String[] args) in C:\myfolder\Invoices\InvoicesHost\Program.cs:line 27

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.Runtime.InteropServices.COMException (0x80000000):

No error.

at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.ReplaceConnection(Object oldConnection, Object newConnection, Object parameterFields, Object crDBOptionUseDefault)

at CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val, Type type)

at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)

at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataTable dataTable)

at Invoices.InvoiceCreator.CreateInvoice(Int32 clientId, InvoiceType invoiceType, DateTime startDate, DateTime endDate) in C:\myfolder\Invoices\Invoices\InvoiceCreator.cs:line 254

at Invoices.InvoiceCreator.CreateOtherInvoices(DateTime startDate, DateTime endDate) in C:\myfolder\nvoices\Invoices\InvoiceCreator.cs:line 160

at Invoices.InvoiceCreator.CreateInvoices(DateTime invoiceDate) in C:\myfolder\Invoices\Invoices\InvoiceCreator.cs:line 63

at InvoicesHost.Program.Main(String[] args) in C:\myfolder\Invoices\InvoicesHost\Program.cs:line 27

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord>

The program '[7636] InvoicesHost.vshost.exe: Managed' has exited with code 0 (0x0).

Mahesh819  Thursday, April 19, 2007 5:42 PM
I have EXACT THE SAME error message.

VS2005 Standard SP1 + Crystal Reports (Develop Edition)XI Release2SP3.

Have a mailprogram that runs in system tray. It auto generates reports and emails them to people. Now, after a few days of running (= generated +- 50 reports), it always crashes with the same error.

---

System.Exception: Het laden van het rapport is mislukt. ---> System.Runtime.InteropServices.COMException (0x80000000): Het maximum aantal verwerkingstaken dat door de systeembeheerder is ingesteld, is overschreden.

at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)

at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)

at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()

--- End of inner exception stack trace ---

at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()

at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)

at CrystalDecisions.CrystalReports.Engine.ReportClass.Load(String reportName, OpenReportMethod openMethod, Int16 parentJob)

at CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport()

at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_Database()

at Cat2Email.Cat2Email.exportOrderbevestiging(String user_id, String order_no) in C:\Documents and Settings\jvg\My Documents\Visual Studio 2005\Projects\Cat2Email\Cat2Email\Cat2Email.cs:line 380

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.




Joostieke  Tuesday, June 17, 2008 7:26 AM
I found a solution.
Use .Dispose() on your report object

public static void ExportAllReport()
{

foreach(int reportKey in listOfKeys)
{
ExportOneReport(reportKey);
}

}


public static void ExportOneReport(int reportKey)
{
MyReport myReport = new MyReport ();
myReport .Load("myreport.rpt");

// Logic to set database connection, export or print

myReport.Dispose();

}
hepieter  Thursday, October 08, 2009 2:25 PM

You can use google to search for other answers

Custom Search

More Threads

• how to develop Crystal Reports
• PrintToPrinter failed to print
• Crystal Report Login Dialog Box pop up
• sort control problem
• Replacing the logo in a report
• How to use CrystalReport Viewer built in VB.NET 2005 to support Khmer Unicode
• Accessing Crystal reports without .net being installed
• Unknown error when run Crystal Report in Chinese WinXP
• Connection Information
• Date format