I have a C# windows service which is running under the NetworkService account. It occasionally needs to print a Chart object which I do by simply calling:
chart.Printing.Print(false); // suppress the Printer Dialog
The weird thing is it seems works fine running as a console application.
The only way it will work is if I run the service under a local admin account.
You probably needed access granted for System.Drawing.Printing.PrintingPermission . Reading the documentation , you find the following:
Classes within the System.Drawing.Printing namespace are not supported for use within a Windows service or ASP.NET application or service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.