cancel
Showing results for 
Search instead for 
Did you mean: 

Program crashes while printing: ntdll.dll, crqe.dll, crpe32.dll

Former Member
0 Kudos

I made a windows service host application that validates product that is loaded in trucks. When a truck gets dispatched, the application prints a load manifest report.

I initially used the CR2005 runtime for this job and that solution has been running for two years on 6 sites without a problem.

Because of customer demands we decided to switch over to Crystal Reports 2008, and I recompiled the program with the CR modules for the 2008 runtime.

After I put the solution in production, the host application started crashing after a couple of hours when printing reports.

The process is just killed, and the application itself doesnu2019t log anything. In the windows event viewer however, exceptions are written. One entry for every crash, but they refer to a couple of different modules. The exceptions are listed below.

On a restart, the first couple of reports print just fine. After a while a new print takes the host down.

Iu2019ve been debugging this for weeks now, and I donu2019t get any further. The only weird thing I notice is that if I use a console mode application to run the host (as opposed to a windows service) the problem doesnu2019t seem to occur.

When I make a service out of the console mode application using SrvAny however, the program starts crashing again.

Iu2019m pulling my hair out here. I hope someone came across this before and knows how to solve it.

Regards,

Wim!

Installation:

OS: Windows server 2003 R2

Database: Oracle XE database

DB connection: Oracle in XE ODBC driver

CR runtime: cr2008fp32_redist.zip

Host application: Windows service made in C#.Net with Visual Studio 2005 (.net 2.0 framework)

Service type: Currently it is a System service, but I tried setting it up as a network service a a user service (admin user) as well without any result.

CR references: CrystalDecisions.CrystalReports.Engine, 12.0.2000.0

CrystalDecisions.Shared, 12.0.2000.0

CR designer: Stand-alone CR 2008 developer version 12.0.0.683

Errors found in thw Windows event viewer:

Faulting application dockmanagerhostservice.exe, version 2.1.0.9, stamp 4cd6da5a, faulting module unknown, version 0.0.0.0, stamp 00000000, debug? 0, fault address 0x00000000.

Faulting application dockmanagerhostservice.exe, version 2.1.0.9, stamp 4cd6da5a, faulting module mfc80u.dll, version 8.0.50727.4053, stamp 4a595928, debug? 0, fault address 0x00023c4d.

Faulting application dockmanagerhostservice.exe, version 2.1.0.8, stamp 4cc32bed, faulting module ntdll.dll, version 5.2.3790.4455, stamp 49900d60, debug? 0, fault address 0x00010a5b.

Faulting application dockmanagerhostservice.exe, version 2.1.0.8, stamp 4cc32bed, faulting module crqe.dll, version 12.3.2.753, stamp 4c98bea9, debug? 0, fault address 0x000a3b00.

Faulting application dockmanagerhostservice.exe, version 2.1.0.8, stamp 4cc32bed, faulting module crpe32.dll, version 12.3.2.753, stamp 4c98cc27, debug? 0, fault address 0x004c9d8c.

Edited by: Rob Hulsen on Nov 9, 2010 4:18 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This is the executing code:

Executing code:

private void EnqueuePrintJob(PrintJobWrapper printJob)
{
    if (string.IsNullOrEmpty(HostSite.Settings.LoadManifestReport) ||
        !File.Exists(HostSite.Settings.LoadManifestReport))
    {
        log.Log("PrintLoadManifest", string.Format("Load manifest report {0}\ncould not be found", HostSite.Settings.LoadManifestReport),
            LogSeverity.Exception);

        ShowClientMessage(printJob.InitiatingClient, MessageIcon.Warning,
            "Unable to print",
            string.Format("Report: {0}\ncould not be found", HostSite.Settings.LoadManifestReport));
        
        return;
    }

    // Print reports in dedicated thread!

    lock (printQueue)
    {
        printQueue.Enqueue(printJob);
    }

    lock (printingStartedLock)
    {
        if (!printingStarted)
        {
            printingStarted = true;
            printThread = new Thread(new ThreadStart(AsyncProcessPrinterQueue));
            printThread.Name = "PrintThread";
            printThread.Start();
        }
    }
}

// Lock to make sure printingStarted flag is atomic
private object printingStartedLock = new object();
// Flag to see if processScannerQueueThread is already processing messages
private bool printingStarted = false;

Former Member
0 Kudos

Second part of AsyncProcessPrinterQueue

while (todo > 0)
        {
            lock (printQueue)
            {
                job = printQueue.Dequeue();
            }

            try
            {
                try
                {
                    loadManifest.SetParameterValue("MasterbatchId", job.MasterbatchId);
                    loadManifest.SetParameterValue("DestinationId", string.Empty);
                }
                catch (Exception ex)
                {
                    log.Log("AsyncProcessPrinterQueue", ex);

                    List<string> clients = new List<string>();
                    clients.Add(job.InitiatingClient);

                    lock (printQueue)
                    {
                        lock (printingStartedLock)
                        {
                            while (printQueue.Count > 0)
                            {
                                job = printQueue.Dequeue();
                                if (!clients.Contains(job.InitiatingClient))
                                    clients.Add(job.InitiatingClient);
                            }

                            foreach (string client in clients)
                                ShowClientMessage(
                                    client,
                                    MessageIcon.Warning,
                                    "Unable to print",
                                    "Could not print.\nCheck the compatibility of the crystal report");

                            printingStarted = false;
                            return;
                        }
                    }
                }

                // When true is returned, data is copied from the history database, and needs to be deleted afterwards.
                doUnprepare = HostSite.dm.PreparePrinting(job.MasterbatchId);

                loadManifest.PrintOptions.PrinterName = job.Printer;
                loadManifest.PrintToPrinter(job.Copies, true, 0, 0);

                // Delete data from live database when copied from history database
                if (doUnprepare)
                    HostSite.dm.UnpreparePrinting(job.MasterbatchId);
            }
            catch (Exception ex)
            {
                log.Log("AsyncProcessPrinterQueue", ex);

                ShowClientMessage(
                    job.InitiatingClient,
                    MessageIcon.Warning,
                    "Unable to print",
                    string.Format("Could not print masterbatch {0} to printer {1}", job.MasterbatchId, job.Printer));
            }

            lock (printQueue)
            {
                lock (printingStartedLock)
                {
                    todo = printQueue.Count;
                    printingStarted = (todo > 0);

                    if (!printingStarted)
                        return;
                }
            }
        }
    }
    finally
    {
        // Needs to be disposed to prevent getting a 
        // "The maximum report processing jobs limit configured by your system administrator has been reached"
        // exception.
        loadManifest.Close();
        loadManifest.Dispose();
        GC.Collect();
    }

    // Thread end
}

Edited by: Rob Hulsen on Nov 9, 2010 4:23 PM

saurabh_pathak
Active Contributor
0 Kudos

Hi Rob,

Please go through [How Printer Driver Options Affect a Report|http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/a09051e9-721e-2b10-11b6-f9c65c64ef29]

Also make sure that you have latest printers installed on Production machine.

If above does not help then please provide:

1) CR version and it's patch level

2) VS version

3) Web or Windows application?

Thanks,

Saurabh

Former Member
0 Kudos

Hi Saurabh,

It's very unlikely it is a printer problem because it works a couple of times, and then all of a sudden the host crashes on a next print.

Clients don't print reports. They send a request to the host. The host queues the requests in a FIFO and prcosses them one by one in a seperate thread.

Answers:

1) CR 2008 runtime patch 3.2

2) VS2005

3) The host is a windows .net service, the client is a windows .net forms application. Clients and host communicate using .net remoting, but then again, the client/host communication can't be the problem becasue the client requests do arrive at the host and the host is the only application printing.

Wim!

(Rob is a co-worker of mine. My registration with SAP failed and now I can't register anymore. That's why)

saurabh_pathak
Active Contributor
0 Kudos

Hi Wim,

Why take chances?

Upgrading your printer drivers would be the only suggestion from my side at this point.

It would be great if you could share printer driver version.

You can also give a try to [crpe logging|] and check what is the reason for crash.

Thanks,

Saurabh

Edited by: Saurabh.Pathak on Nov 10, 2010 4:42 PM

0 Kudos

Hi Wim,

Can you clarify a few things for me?

You indicated these are your versions:

Merge Modules 3.2.

CR references: CrystalDecisions.CrystalReports.Engine, 12.0.2000.0

CrystalDecisions.Shared, 12.0.2000.0

CR designer: Stand-alone CR 2008 developer version 12.0.0.683

Can you update your development PC with CR SP3 and FP 3.2 and then rebuild your project? Assuming you have CR Designer and runtime installed on the same developer PC and VS 2005. Building your app with the original SP0 release and then distributing the latest runtime is not the ideal way to do things and can definitely cause problems.

What may be happening is your app is calling a CR API which may have been updated and altered resulting in likely a memory leak or possibly corrupting the memory space. The crash could be the result of calling into a pointer outside of the an allotted memory in one of our structures.

Also, depending on the printer you are using depends on which driver you should use. If the printer is an older printer the drivers that are installed with current Windows is likely the best one to use and not the latest, which could be 5 or more years old. Most of those old legacy printers are not .NET framework aware and still use the DEVMODE structure which works fine in CR, because we still use it, but in a .NET app the app itself is going to use the .NET framework printer common controls and resources.

So if you are using, for example an older Dot Matrix printer then use the driver off the windows CD. If you are using a current printer and that printer manufacturer has a driver specific for the OS your app is installed on then please do get the latest driver.

As for getting more info can you go to windows and download Debugdiag if you don't have it and set it up to capture a dump file on your app crashing. Analyze it and see if it shows more info in which module/dll it is crashing in.

Also, does your printer have on board memory or is it using the local PC as the printer memory cache? This may explain why you get a few reports printed and then it starts crashing.

Finally, rather than using the Report Engine can you rebuild using RAS ( report application server ) and then use the PrintOutputController. It is much better than the PrintToPrinter method and that method is part of the CR Basic for VS and typically does not get any patches applied to it.

printing looks like this:

System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptionsClass();

rptClientDoc.PrintOutputController.ModifyPrintOptions(MYPRTOpts);

Relatively easy to upgrade your app to use RAS and is much more robust than using the engine....

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

ISCDReportClientDocument rptClientDoc;

Open method:

if (openFileDialog.ShowDialog() == DialogResult.OK)

{

btnOpenReport.Enabled = false;

btnSaveRptAs.Enabled = false;

object rptName = openFileDialog.FileName;

rpt.Load(rptName.ToString(), OpenReportMethod.OpenReportByTempCopy);

rptClientDoc = rpt.ReportClientDocument;

...

Thank you

Don

Former Member
0 Kudos

Hi Don,

Thank you for your respons.

I think your reply contains valueable information.

I never succeeded in upgrading my development system with SP3 and fp 3.2. After I read your post I started playing with it again, and found out that I had to uninstall the CR 2008 designer first, and then install the SP3 full build.

I did that, and after that I could install FP 3.2

So far so good.

What I noticed is, that the assembly version of CrystalDecisions.CrystalReports.Engine and CrystalDecisions.Shared did not change after the reinstall.

They are still version 12.0.200.0 with a modified date in April 2010. I couldn't find any new version in the Add References box in Visual Studio.

Is that ok? Because those are the only modules which are linked in my assemblys, right?

The printer is a brand new HP LaserJet 9050 PCL 5e. The latest drivers are installed. I'm not sure if it has on-board memory, but I guess it has.

Using the RAS server sounds like a good option too. I've never done that before, so I should get my feet wet on that a little first. Thanks for the code you provided. That'll help me get along.

Unfortunately I applied a patch now with our customer so they can continue working. Using platform invocation I kick off another process what does the printing. In that way it can never kill the host process.

I'm still commited to find and solve the root cause, but because the customer (working in a 27/7 operation) is satisfied now, it's hard to get downtime to do testing, and I can't get it reproduced on my development machine.

I hope to have some answers at the end of next week.

Can you please confirm that those assembly versions should be 12.0.2000.0, and that you still think this might solve the problem?

Thanks in advance.

Wim!

0 Kudos

Hi Wim,

Great to see you have it all working, Sorry I should have mentioned that Full builds require an uninstall first. And also nice to see you spawn a separate thread for each print job... Our BOE servers do the same, it makes managing errors much easier and like you it does not kill the host service and also disposes of the memory when the thread is killed....

We kept the versions of the assemblies the same in your project so you technically don't need to re-build your app if you updated the runtime, always a good thing to do though. If you browse the \windows\assembly folder you'll see the CR ones. Righ click on the dll and then look at the properties and you'll see the actual version of the dll's, something like: 12.3.2000.601 - 3 is the Service Pack installed and 601 is the Fix Pack or minor version. Fix Packs don't update everything so you will likely see minor differences. With SP's you'll see the minor versions are all the same.

Back to the issue. I'm not sure we'll be able to figure the cause over forums but to let you know there are major dependencies on the C++ runtime and the mfc dll's.

And the one that is used a lot and also in our database drivers is this one:

Faulting application dockmanagerhostservice.exe, version 2.1.0.9, stamp 4cd6da5a, faulting module mfc80u.dll, version 8.0.50727.4053, stamp 4a595928, debug? 0, fault address 0x00023c4d.

Which then typically throws the error in:

Faulting application dockmanagerhostservice.exe, version 2.1.0.8, stamp 4cc32bed, faulting module ntdll.dll, version 5.2.3790.4455, stamp 49900d60, debug? 0, fault address 0x00010a5b.

Then it cascades into our query builder dll:

Faulting application dockmanagerhostservice.exe, version 2.1.0.8, stamp 4cc32bed, faulting module crqe.dll, version 12.3.2.753, stamp 4c98bea9, debug? 0, fault address 0x000a3b00.

Which of course is all handled by the main report engine:

Faulting application dockmanagerhostservice.exe, version 2.1.0.8, stamp 4cc32bed, faulting module crpe32.dll, version 12.3.2.753, stamp 4c98cc27, debug? 0, fault address 0x004c9d8c.

It may be due to the version of Oracle ODBC driver/client they are using. CR spawns a separate thread for each database connection. This intern uses up one more thread in the DB client engine. I'm not familiar with that client so it may be there are limits to the number of open connections it is capable of handling or creating. I assume you are not using that same version of the Oracle Server/Client, which is likely why you can't duplicate the issue.

CR should disconnect when the report is disposed of but it may not because of the client they are using or it may be the client itself is not releasing the thread in a timely manor and then when a new report is run there are no new connections available and thus the errors.

Now with all of this info now download, if you don't have it already, DebugDiag from MS and run it on their system. The next time it crashes it should generate the dump file. If you analyze it you should see the fault and it may tell you which API in CR that caused the error. I may have to get the CR PDB's to you though.

What they may have to do is use a version of Oracle that we have tested with like 11g etc. Or try using the [CR DataDirect|https://smpdl.sap-ag.de/~sapidp/012002523100008666562008E/cr_datadirect53_win32.zip] drivers.

Of course this is going to be a lot of work on a production server. And it may require more code changes, you'll have to test on your system to see what happens if you use the CR driver in your DSN. It may just work but you may need to verify the reports.

One final suggestion, and this may not have anything to do with this issue. Search for a file called u2lcom.dll and rename it to *.org. Restart your service and test again. It can be done ONLY if you are not using any COM UFL's in your reports.

Thanks again

Don

0 Kudos

And to get you going on using inProc RAS check these sample out:

Root Page

http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsHome

Enterprise Samples (including managed and unmanaged ras)

http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsSDKSampleApplications

Non-Enterprise Samples

http://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsSDKSampleApplications

Exporting Samples (RAS)

http://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples#NETRASSDKSamples-Exporting%2FPrinting

Most use a connection to BOE and Managed reporting so you can simply delete that part and use the open method as noted previously.

Or for scalability you can leave it in. BOE comes with RAS also running as a Service. So for scalability for your application if your users go above the limits of stand alone CR with a few lines of code and a configuration file that your app can use to determine if BOE is installed, it's quite easy to program this all in. The next step is to use the BOE Job server to run your reports which gives you even more power....

Thanks again

Don

Answers (1)

Answers (1)

Former Member
0 Kudos

First part of AsyncProcessPrinterQueue

private void AsyncProcessPrinterQueue()
{
    bool doUnprepare;
    int todo;
    PrintJobWrapper job;
    ReportDocument loadManifest;

    try
    {
        loadManifest = new ReportDocument();

        try
        {
            loadManifest.FileName = HostSite.Settings.LoadManifestReport;
            loadManifest.SetDatabaseLogon(HostSite.dm.UserName, HostSite.dm.Password);
            loadManifest.SetParameterValue("Ccode", HostSite.Settings.Ccode);
        }
        catch (Exception ex)
        {
            // If excecution fails at this point, the document needs to be disposed
            loadManifest.Dispose();
            throw ex;
        }
    }
    catch (Exception ex)
    {
        log.Log("AsyncProcessPrinterQueue", ex);

        List<string> clients = new List<string>();

        lock (printQueue)
        {
            lock (printingStartedLock)
            {
                while (printQueue.Count > 0)
                {
                    job = printQueue.Dequeue();
                    if (!clients.Contains(job.InitiatingClient))
                        clients.Add(job.InitiatingClient);
                }

                foreach (string client in clients)
                    ShowClientMessage(
                        client,
                        MessageIcon.Warning,
                        "Unable to print",
                        "Could not print.\nCheck if the Crystal Report Distributable is installed on the server");

                printingStarted = false;
                return;
            }
        }
    }

    try
    {
        lock (printQueue)
        {
            todo = printQueue.Count;
        }

        

Edited by: Rob Hulsen on Nov 9, 2010 4:23 PM