.Net Crystal Report printing application running on termianal service connection errors when session is disconnected

StackOverflow https://stackoverflow.com/questions/602295

Question

I have created a .Net application to run on an App Server that gets requests for a report and prints out the requested report.

The C# application uses Crystal Reports to load the report and subsequently print it out.

The application is run on Server which is connected to via a Remote Desktop connection under a particular user account (required for old apps). When I disconnect from the Remote Session the application starts raising exceptions such as:

Message: CrystalDecisions.Shared.CrystalReportsException: Load report failed

This type of error is never raised when the Remote Session is active. The server running the app is running Windows Server 2003, my box which creates the connection is Windows XP.

I appreciate this is fairly weird, however I cannot see any problem with the application deployment I have created.

Does anyone know what could be cause this issue?

EDIT: I bit the bullet and created the application as a windows service, obviously this doesn't take long I just wasn't convinced it would solve the problem. Anyway it doesn't!!!

I have also tried removing the multi-thread code that was calling the print function asynchronously. I did this in order to simply the app and narrow down the reason it could fail. Anyway, this didn't improve the situation either!

EDIT: The two errors I get are:

System.Runtime.InteropServices.COMException (0x80000201): Invalid printer specified. at CrystalDecisions.ReportAppServer.Controllers.PrintOutputControllerClass.ModifyPrinterName(String newVal) at CrystalDecisions.CrystalReports.Engine.PrintOptions.set_PrinterName(String value) at Dsa.PrintServer.Service.Service.PrintCrystalReport(Report report)

The printer isn't invalid, this is confirmed when 60 seconds later the time ticks and the report is printed successfully.

And

The request could not be submitted for background processing. at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.GetLastPageNumber(RequestContext pRequestContext) at CrystalDecisions.ReportSource.EromReportSourceBase.GetLastPageNumber(ReportPageRequestContext reqContext) --- End of inner exception stack trace --- at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e) at CrystalDecisions.ReportSource.EromReportSourceBase.GetLastPageNumber(ReportPageRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at Dsa.PrintServer.Service.Service.PrintCrystalReport(Report report)

EDIT:

I ran filemon to check if there were any access issue. At the point when the error occurs file mon reports

Request: OPEN | Path: C:\windows\assembly\gac_msil\system\2.0.0.0__b77a5c561934e089\ws2_32.dll | Result: NOT FOUND | Other: Attributes Error

Was it helpful?

Solution

Our particular problem has been solved. Basically when the reports were created they were saved with information about printers. Basically a particular printer had been set for the report and saved.

This printer no longer exists which is why the report had started failing. Basically we had to open the report designer and remove any association with printers in the report.

OTHER TIPS

We have encountered these errors several times in the past few years. Many times I wished for some more specific error message.

First, I would verify that there aren't multiple Crystal Reports versions installed. In our expereince, we found that Crystal Reports 9.0 doesn't seem to play well with 10. Uninstalling version 9 seemed to help some of our customers. If both are installed, I highlly recommend uninstalling both, then re-installing Crystal Reports 10.

One of our earliest Crystal Reports errors was the dreaded "The request could not be submitted for background processing." Reports would work fine for a while, then suddenly they would stop. After looking at the code, I found a place where we were not disposing of a ReportDocument. Correctly disposing this document fixed the issue.

Lately, we hit a spat of "The request could not be submitted for background processing." and "Invalid Printer" errors. One customer's server had several network printers defined by IP address. Printing would work just fine for a while, then suddenly, bam, the customer got the "Invalid Printer" error and called our support.

A fellow developer fixed the "Invalid Printer" problem by doing all of the following things:

  1. Edit and save the .rpt file in Visual Studio 2005. We had been keeping the report format compatible with Crystal Reports 9, because we wanted our changes to be distributable to our customers still using older versions.
  2. Save Crystal Reports files with the "No Printer" option. From the Visual Studio 2005 menu, select Crystal Reports/Design/Printer Setup, then select the "No Printer" check box.
  3. We changed a formula that displayed "Page N of M" from something strange like this:

"Page " + Left (CStr (PageNumber), Length (CStr (PageNumber)) - 3) +
" of " + Left (CStr (TotalPageCount), Length (CStr (TotalPageCount)) - 3)

to this:

"Page " + CStr(PageNumber,0) + " of " + CStr(TotalPageCount,0)

Unfortunately, I have no idea which (any or all) of the above actions may fixed the error. I say "may", because for all I know, the error magically went away because of some IT network change.

Finally, have you read this white paper? While it did not necessarily solve our problems, it was very interesting.

If you create a window service wrapper for your application, it means that it will continue to run regardless of users logged in. It can also be set to start up automatically. I think that because you are using an actual application, and not a windows service it is not actually running once you logout of a session on the server.

Here is an example on Code Project:

http://www.codeproject.com/KB/system/WindowsService.aspx

Are you sure you are "disconnecting' you remote session as opposed to "logging off". I disconnect my sessions to a nt server 2003 all the time and everything to continues to run just fine. Logging off on the other hand will kill the apps running in that session.

What is your o/s server running?

In Order to solve the problem that you have described you need to focus in on what your problem is.

I have recieved the Message: CrystalDecisions.Shared.CrystalReportsException: Load report failed a number of times and it is due to the fact that you can't access the report. Either it doesn't exist or in your situation the you are not connected to the machine. The error is not due to anything printing related.

I had an obscure issue that was similar to this, except it was a (shock-horror) automation issue with Excel. I found the application worked fine when I had my remote desktop session connected, but once disconnected, it would give automation errors relating to the default printer.

I believe the issue relates to how the default printer is set when you connect with remote desktop. Assuming you have a .rdp file for initiating your remote desktop session, if you edit it, then select the "Local Resources" tab, you can see whether or not you share your local printer on the remote session.

If it is enabled, this means when you connect, your local default printer becomes the default printer on the remote machine. When you disconnect, your application's default printer will still possibly refer to the now unavailable default printer from your local machine.

You should be able to solve this, by ensuring you don't share your local printer, by deselecting the Printer checkbox from the "Local Resources" tab.

An easier solution would be to disable "printer redirection" on the server. See https://serverfault.com/questions/5646/how-do-i-disable-remote-printers-using-group-policy for more information.

If you are looking in detail how to

add checkboxes into crystal reports on a boolean feild and if the boolean field is false

uncheck else check the checkbox look at this article

http://checkboxcrystalreport.blogspot.com/2009/07/printing-checkbox-in-crystal-report-for.html

After long googling i found this link but didnt try, coz of no any other free server.

http://www.microsoft.com/technet/security/bulletin/ms04-017.mspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top