2

I want to select printer in Silverlight program, just like ATM or POS that will automatically print without selecting printer.

I browse internet and found: http://bytes.com/topic/c-sharp/answers/255914-set-default-printer-machine, it says that using System.Management package, using ManagementObject and ManagementBaseObject class, but I cannot add/import the class.

How to add using System.Management in Silverlight, or is any other way to selectt printer in silverlight code?

Regards, Imam

4

1 回答 1

2

您不能在 Silverlight 中本机执行此操作。“System.Management包”(如您所说)与 Silverlight 运行时不兼容,它是为完整的 .NET CLR 设计的。

如果您使用 Elevated Trust 运行 OOB,那么您可以使用AutomationFactory来实现此目标:-

 var scriptNetwork = AutomationFactory.CreateObject("WScript.Network");
 scriptNetwork.SetDefaultPrinter("nameOfPrinterToSetAsDefault");
于 2011-12-08T12:46:48.377 回答