我已经构建了一个用于打印文档的应用程序
当使用Visual Studio调试模式运行应用程序时,我可以使用接收可用打印机的列表
PrinterSettings.InstalledPrinters
然后,我选择其中一个使用打印文档
PrintDocument printDocument = new PrintDocument();
printDocument.PrinterSettings.PrinterName = "Fax" ; //or any other listed printer that is returned from the method above
printDocument.PrintPage += printDocument_PrintPage;
printDocument.Print();
void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawRectangle(new Pen(Color.Red,10),new Rectangle(0,0,100,100));
}
这在Visual Studio内部工作,但当我将其迁移到同一台计算机上的IIS 7根文件夹时,会出现错误"没有安装打印机">
注意:当我将应用程序部署到根文件夹时,我仍然可以获得相同的可用打印机列表,但当调用Print()方法时,web应用程序会抛出错误。
我正在使用命名空间System。绘画打印
更新:我确实检查了系统。打印命名空间参考页,它还显示一个框,上面写着:
"System.Printing命名空间中的类不是支持在Windows服务或ASP。NET应用程序或服务">
我也遇到了同样的问题,你可以在服务中看到RPC(在服务中)是如何运行的(网络服务|本地系统),并将其放入IIS adance设置Identity的应用程序池中。
我希望我能帮忙!。