我做了一个winform的水晶报表,需要批量打印报表(VS2005自带的水晶报表),开始打印很正常。但是数量多了之后就会报错:
检测到 CallbackOnCollectedDelegate
Message: 对“CrystalDecisions.ReportAppServer.DataSetConversion!CrystalDecisions.ReportAppServer.DataSetConversion.DataSetConverter+CrdbAdoPlusDelegate::Invoke”类型的已垃圾回收委托进行了回调。这可能会导致应用程序崩溃、损坏和数据丢失。向非托管代码传递委托时,托管应用程序必须让这些委托保持活动状态,直到确信不会再次调用它们。大侠们有没有遇到过这样的问题?是如何解决的?

解决方案 »

  1.   


    string sSelectCommand = "select cl.cname as Claxx,Dgaddre,cus.wname as Saller,substring(bcode,1,8) as boxcode,boxcode,bcode,listno,task.fjport,vbeln from wcs_task as task,wcs_customer as cus,wcs_claxx as cl where listno = " + "'" + sListno + "'" + "and task.saller = cus.werks and task.claxx = cl.claxx"; //listno是主键;
                string sConnectionString = worker.sConnectionString;            DataSet myDataSet = new DataSet();            SqlConnection mySqlConnection = new SqlConnection(sConnectionString);
                SqlCommand mySqlCommand = new SqlCommand(sSelectCommand, mySqlConnection);
                SqlDataAdapter myDataAdapter = new SqlDataAdapter();            myDataAdapter.SelectCommand = mySqlCommand;
                myDataAdapter.Fill(myDataSet, "sSelectCommand");           // LoginBoxSourse.Load(Application.StartupPath,"C01Split.rpt");
                LoginBoxSourse.SetDataSource(myDataSet.Tables["sSelectCommand"]);            //还原bcode字段   ------------------在这里还原bcode字段可行吗?
                worker.WriteBcode(sListno, sBcode, false);
                PrintDocument prtdoc = new PrintDocument();
                string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName;            try
                {                LoginBoxSourse.PrintOptions.PrinterName = strDefaultPrinter;
                    LoginBoxSourse.PrintToPrinter(1, true, 1, 9999);                 = true;            }            catch (Exception e2)
                {
                     = false;
                    reason = e2.Message;
                }            prtdoc.Dispose();
                return ;