我正在开发一个应用程序,其中一个模块是收据打印。 我已经为打印机编码了,但是当我执行程序时,我在我的一个方法中得到一个异常。这是我得到例外的代码。
打印机:PMX热敏收据打印机 型号:PMX 80220
private PosPrinter GetReceiptPrinter()
{
PosExplorer posExplorer = new PosExplorer(this);
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "MYPRINTER");
return (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice); //Here I am getting an exception "ArgumentNullException"
}
答案 0 :(得分:0)
这里的DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "MYPRINTER");
似乎返回null。确保他的行实际上正在返回DeviceInfo。