views:

351

answers:

2

I got an exception with message "No printers are installed." while printing a report for depolyed release of our website.
I use _rptDocument.PrintToPrinter(1, false, 0, 0); to print a report.

I got that exception, even I've more than one printer installed on my machine. Also, I don't get that exception while development, everything while development is going fine.

I used "Publish Web Site" and "Web Project Deployment" options to publish/deploy website, but I got the same result.

Any suggestions?

Edit

Sample Code

DataSet dsResult = null;
rptDocument = new ReportDocument();
rptDocument.Load(Server.MapPath("WINGR0040.rpt"));

// Fetch report data.
...

rptDocument.SetDataSource(dsResult);

// Print report.
rptDocument.PrintToPrinter(1, false, 0, 0);
A: 

Have you added a printer on the Web server under the user account that site runs under?

Have you tried setting the printer name first?

Report.PrintOptions.PrinterName = printerName;

If your site runs under an account e.g DOMAIN\WebService you need to ensure that this user account has a default printer.

You could also try setting the printer name like this:

Report.PrintOptions.PrinterName = this.printDocument1.PrinterSettings.PrinterName;

This will get the default printer.

This article may help you get this working.

EDIT:

This article on MSDN describes how printing can be acheived using Crystal Reports and ASP.NET. If you are not implementing either of these solutions then I don't think you will be able to print client side.

The .cab file mentioned in the MSDN link can be found here:

Visual Studio 2005 or Visual Studio 2008

Without you posting further code and more detail as to how you are generating the report I don't I am going to be able to fully answer your question.

Thanks

Barry
Website is published on another server rather than client machine.For printer, both web server and client's machine have an installed printer.
Ahmed
Under the user account that the site runs? Also, this will print it from the server NOT the client. Is this what you want?
Barry
No, I need to print report from client machine? For this, "Under the user account that the site runs?" do you mean that I should give certain permissions for every client machine, or what do you mean exactly?
Ahmed
I have updated my answer, thanks Barry
Barry
The PrintDocument and PrinterSettings are for Windows Form projects only, or I missing something?
Ahmed
The title of the article is `Printing Web based reports with Crystal Reports for Visual Studio .NET`
Barry
Yes, but it doesn't solve the problem. My issue, that I need to print report from client machine using his machine printer, not server printer!
Ahmed
Have you noticed this in link you have posted?Note: Only Internet Explorer supports ActiveX controls. Printing from a non-Internet Explorer client (FireFox, Safari, Mozilla, and others) reverts to the PDF export dialog.Sure, this is the case I've, so this solution will not work for me.
Ahmed
A: 

I would really export the report to PDF so the user prints at their desktop printer. However maybe the Print Spooler Service is stopped on the iis server so crytsal is confused.

ggonsalv
Export report to PDF will solve the issue, but that solution is not acceptable for customer. Using print button should print document directly, no need to export to it, he said.
Ahmed
For you to print from the server, is a security risk since by default the account iis uses for the app domains is restricted. Also this will **only** work in an intranet setting.
ggonsalv
What does this mean? "Also this will only work in an intranet setting"?
Ahmed
@ggonsalv: is IIs user need specific permission for Print Spooler Service?
Ahmed