这是代码
private PosPrinter GetReceiptPrinter()
{
PosExplorer posExplorer = new PosExplorer();
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, sPOSPrinterName);
return (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice);
}
我在加紧以下一行时遇到错误:
PosExplorer posExplorer = new PosExplorer();
我的收据打印机设备:hp a798
我已在app.config
添加了此代码<runtime>
<NetFx40_LegacySecurityPolicy enabled="true" />
</runtime>
按照约翰的说法,这就是例外:
System.TypeInitializationException未处理
的HResult = -2146233036
Message ='Microsoft.PointOfService.Management.Explorer'的类型初始值设定项引发异常
来源= Microsoft.PointOfService
类型名= Microsoft.PointOfService.Management.Explorer
堆栈跟踪:
在Microsoft.PointOfService.Management.Explorer.CreateExplorer()
在Microsoft.PointOfService.PosExplorer.LoadExplorer()
在Microsoft.PointOfService.PosExplorer.Initialize()
在Microsoft.PointOfService.PosExplorer..ctor()