C# 在IIS7中Visual Studio 2013之外运行站点时未检测到打印机

C# 在IIS7中Visual Studio 2013之外运行站点时未检测到打印机,c#,asp.net-mvc-4,iis-7,system.drawing,C#,Asp.net Mvc 4,Iis 7,System.drawing,我已经构建了一个用于打印文档的应用程序。 使用Visual Studio-调试模式运行应用程序时,我可以通过以下方式接收可用打印机的列表: PrinterSettings.InstalledPrinters 然后,我选择其中一个来打印文档,使用: PrintDocument printDocument = new PrintDocument(); printDocument.PrinterSettings.PrinterName = "Fax" ; //or any other listed

我已经构建了一个用于打印文档的应用程序。
使用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.Drawing.Printing

更新:我确实检查了系统。打印名称空间参考页时,它还会显示一个框,上面写着:

“系统中的类。打印命名空间不可用。” 支持在Windows服务或ASP.NET应用程序中使用,或 服务。”


我也有同样的问题,您可以在服务中看到RPC(在服务中)是如何运行的(网络服务|本地系统),并将其放在IIS adance设置标识的应用程序池中


我希望我能帮忙

打印机是每个用户的帐户设置。我猜应用程序池没有在您的用户帐户下运行。另外,:“System.Drawing.Printing命名空间中的类不支持在Windows服务或ASP.NET应用程序或服务中使用。”由于我能够获得可用打印机列表,我认为这不是用户帐户设置问题,感谢您提供链接