C#POS - “Microsoft.PointOfService.Management.Explorer”的类型初始化程序引发了异常

时间:2018-06-11 06:35:51

标签: c# pos

  1. 这是代码

    private PosPrinter GetReceiptPrinter()
    {
        PosExplorer posExplorer = new PosExplorer();
        DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, sPOSPrinterName);
    
        return (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice);
    }
    
  2. 我在加紧以下一行时遇到错误:

    PosExplorer posExplorer = new PosExplorer();
    
  3. 我的收据打印机设备:hp a798

  4. 我已在app.config

    添加了此代码
    <runtime>
        <NetFx40_LegacySecurityPolicy enabled="true" />
    </runtime>
    
  5. 按照约翰的说法,这就是例外:
    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()

0 个答案:

没有答案