locked
Error "CallbackOnCollectedDelegate was detected" found in VS2005(final) RRS feed

  • Question

  • could any one help me with following error:

    when i run an vb.net 2005 application with embeded crystal report and get following error message:

    "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."

    The codes throw out this exception are:

    dim oReport as new ReportDocument
    ...
    ...
    dsReportData = New DataSet("InvoiceData")
    for i = 1 to 1600
        'load different dsReportData
        ...
        ...
        oReport.SetDataSource(dsReportData) ' throw out exception when export about 5 PDF files
        oreport.export() 'export to PDF file
    Next

    thanks in advance

    Monday, November 14, 2005 11:25 PM

Answers

  • Can you please try to move the following line in the for loop and also add oReport.close in the loop?  

    dim oReport as new ReportDocument

    Thanks
    Tuesday, November 15, 2005 2:26 AM
    Moderator

All replies

  • Can you please try to move the following line in the for loop and also add oReport.close in the loop?  

    dim oReport as new ReportDocument

    Thanks
    Tuesday, November 15, 2005 2:26 AM
    Moderator
  • thank you very much. it works now.

    But it runing quite slow, said with my previous code, it working fine with vb.net 2003, i can export 150 PDF files per minute and now i can only export 15 PDF files per minute.

    could you give me a direction how can i speed up a little bit?

    thanks
    Tuesday, November 15, 2005 3:46 AM
  • If you use the same report, you don't have to put dsReportData = New DataSet("InvoiceData") and reportdoucment.close() in the loop.  Please try to move them out of the loop and add reportdocument.Refresh() in the loop after you set datasource.  Hope it will speed up for your exporting.

    Since your code was working with VS 2003, VS 2005 should work in the same way.  Can you please contact TS with the detail codes and machine environment at this site http://support.businessobjects.com?  They will check what the exact problem is.    

    Tuesday, November 15, 2005 10:24 PM
    Moderator
  • Thanks your reply.

    In my code, i use same report with different dataset, that is the reason at my original code (written under vb.net 2003) i put the line
    dsReportData = New DataSet("InvoiceData") outside the loop and with each export finish i add oReport.Refresh(). It working perfect under vb.net 2003.

    under vb.net 2005, if i just export a few PDF files (said 5 to 10) it working fine. Because my application need export thousands of PDF files, and it throws out following exception when the code run at this line oReport.SetDataSource(dsReportData):

    "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."

    could you tell me a little bit more about how can i contact TS?

    thank you very much and appreciate your help



    Tuesday, November 15, 2005 10:41 PM
  • Go to this site http://support.businessobjects.com/ and select Support page.  Under Contact Support, select Report a bug.
    Tuesday, November 15, 2005 11:45 PM
    Moderator
  • thanks for that.

    i have reported a bug to TS. are you able to tell me how can i trace it up? seems to me once i submited a bug its gone. i can't see it from anywhere. Did they reply back to me or i can view it from web site ?


    Wednesday, November 16, 2005 12:52 AM
  • They should reply you.  If not, you can call them.
    BTW, can you please provide more detail codes to load defferent dsReportData in the loop?  I would like to simulate your case to see if I can reproduce the problem.
    Wednesday, November 16, 2005 5:46 PM
    Moderator
  • Thank you for your reply. I haven't received any reply yet.

    The similar details code I used as follow, which generated same error message as above.
    And it use AdventureWorks database from Microsoft and you only need to change connection string and   can run it from your machine.

    the computer environment I have as follow:

    OS: window XP sp2
    Sql: sql server 2005 express
    CR: Crystal Reports for Visual Studio 2005 (V10.2.3600)
    .NET Framework: V.2.0.50727
    vb.net 2005

    appliciate your help

     



      Dim sqladp As SqlClient.SqlDataAdapter
            Try
                Dim dsData As New DataSet, i As Integer

                sqladp = New Data.SqlClient.SqlDataAdapter("SELECT     Sales.Store.Name, Sales.Customer.CustomerID, Person.Address.AddressLine1 AS Address1, Person.Address.AddressLine2 AS Address2, Person.Address.City FROM  Sales.Store INNER JOIN Sales.Customer ON Sales.Store.CustomerID = Sales.Customer.CustomerID INNER JOIN Sales.CustomerAddress ON Sales.Customer.CustomerID = Sales.CustomerAddress.CustomerID INNER JOIN Person.Address ON Sales.CustomerAddress.AddressID = Person.Address.AddressID; ", "Data Source=MZHENG;Initial Catalog=AdventureWorks;Integrated Security=True")
                sqladp.Fill(dsData, "Customer")
                sqladp.SelectCommand.CommandText = "SELECT     OrderDate, TaxAmt, CustomerID FROM         Sales.SalesOrderHeader"
                sqladp.Fill(dsData, "Order")
                Dim oReport As New CrystalReport1
                oReport.SetDataSource(dsData)



                If dsData.Tables(0).Rows.Count > 0 Then
                    Dim dsReportdata As New DataSet, oRow As DataRow, options As New CrystalDecisions.Shared.ExportOptions, oRows() As DataRow

                    dsReportdata.Tables.Add(dsData.Tables("CUstomer").Clone)
                    dsReportdata.Tables.Add(dsData.Tables("Order").Clone)

                    For i = 0 To dsData.Tables(0).Rows.Count
                        dsReportdata.Tables("Customer").Rows.Clear()
                        oRows = dsData.Tables("Customer").Select("CustomerID = " & dsData.Tables(0).Rows(i).Item("CustomerID").ToString)
                        For Each oRow In oRows
                            dsReportdata.Tables("customer").ImportRow(oRow)
                        Next

                        oRows = dsData.Tables("Order").Select("CustomerID = " & dsData.Tables(0).Rows(i).Item("CustomerID").ToString)

                        dsReportdata.Tables("Order").Rows.Clear()
                        For Each oRow In oRows
                            dsReportdata.Tables("Order").ImportRow(oRow)
                        Next
                        oReport.SetDataSource(dsReportdata)
                        'With options
                        '    .ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
                        '    .ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat

                        'End With
                        oReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "c:\temp\" & dsData.Tables(0).Rows(i).Item("CustomerID").ToString & ".pdf")
                        oReport.Refresh()
                    Next
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            Finally
                sqladp = Nothing

            End Try


     

    Thursday, November 17, 2005 4:03 AM
  • does anyone know what wrong with above code? it throws out exception at line

        oReport.SetDataSource(dsReportdata)

    when the program loop throgh around 5 to 10 times.

    appreciate any help!

    Friday, November 18, 2005 1:17 AM
  • Help! Help!Help! Please......

    Has anyone found out the problem showing on the above code. Or can anyone point a right direction to me.


    much appreciate for your help.


    Wednesday, November 23, 2005 12:40 AM
  • Try to locate in ur project if u are using  "GC.Collect" this may creat problem
    Wednesday, August 23, 2006 1:20 PM
  • Seems that daleep havn't study .Net properly..
    Tuesday, March 20, 2007 12:33 PM
  • Hello sir,

     

    I am facing same problem sometimes it runs fine,

    If you found the solution please tell me.

    Thanks in advance

     

    Please reply me as soon as possible

    I am in much need of hellllllllllllllllllllllllllpppppppppppppp

    Thursday, August 9, 2007 8:21 AM
  • I'm running into the same problem.  Can't find any solution online.

     

    Does anyone know of a fix that will allow me to use the same report object while setting the datasource multiple times?  Does anyone know if this is a reported bug?

     

    Thanks in advance!

    Thursday, September 13, 2007 11:19 PM
  •  

    Hi,

    When i try to execute the method below

     Private Sub SetDeviceMode(ByVal Mode As Short)
            Try
                Select Case Mode
                    Case 1 'Mode1
                        DeviceMode = &H2S
                        barRecorderStatus.Items.Item(1).Text = "Mode1(&H2)"
                        chkButtonStatus.CheckState = System.Windows.Forms.CheckState.Unchecked

                    Case 2 'Mode2
                        DeviceMode = &HCS
                        barRecorderStatus.Items.Item(1).Text = "Mode2(&HC)"
                        chkButtonStatus.CheckState = System.Windows.Forms.CheckState.Checked
                    Case Else
                        DeviceMode = 0
                        barRecorderStatus.Items.Item(1).Text = ""
                End Select
            Catch ex As Exception
                Throw ex
            End Try
        End Sub


    I am getting the following error.

    A callback was made on a garbage collected delegate of type 'RECORDER_SAMPLE!RECORDER_SAMPLE.MciFunc+SubClassProcDelegate::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.

     

    Basically this is a VB to Vb.net converted code(VS 2005).Please let me know anymore clarifications required.


    Thanks,
    Shijith

    Friday, February 15, 2008 3:15 PM