开发者

Why can't I print a chart from a windows service using NetworkService account?

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开发者_Go百科

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜