Home » .Net FrameworkRSS

POS Printer Device Enabled - POSControlException Thrown

I'm attempting to print to an NCR 7197 receipt printer using the Microsoft.PointOfService dll that's part of Microsoft POS for .NET SDK.

Here are some of the resources I've examined:

http://social.msdn.microsoft.com/profile/baditala/?type=forum&referrer=http://social.msdn.microsoft.com/Forums/en-US/posfordotnet/thread/ca51f535-ad26-4557-9184-6c1f6ff6223d

http://social.msdn.microsoft.com/Forums/en-US/posfordotnet/thread/d1dd6b1b-62c8-4ca8-9822-607e277d01f6/

http://www.yortondotnet.com/search/label/Pos%20.Net

The simplified C# 2008 code I'm working with is the following:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.PointOfService;


namespace MyOPOSPrinterTest
{
  public partial class frmPOSTest : Form
  {
    PosExplorer posExplorer = new PosExplorer();
    string strLogicalName = "MyTestPrinter";
       


    public frmPOSTest()
    {
      InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
      DeviceInfo oDevicePrinter = posExplorer.GetDevice("PosPrinter", strLogicalName);
      PosPrinter oPrinter = (PosPrinter)posExplorer.CreateInstance(oDevicePrinter);

      try
      {
        if (oPrinter != null)
        {
          oPrinter.Open();
          oPrinter.Claim(1000);
          oPrinter.DeviceEnabled = true;
        }
      }
      catch (Exception exPrinter)
      {
        MessageBox.Show(exPrinter.ToString(), "Warning");
      }
    }
      
    
  }
}

I get a POSControlException on the following line:

oPrinter.DeviceEnabled = true;

Additional details on the exception:

"Microsoft.PointOfService.PosControlException: Failed to set property DeviceEnabled

at Microsoft.PointOfService.Legacy.LegacyProxy.SetProperty(String propertyName, Object propertyValue)

at Microsoft.PointOfService.Legacy.LegacyProxy.set_DeviceEnabled(Boolean value)

at Microsoft.PointOfService.Legacy.LegacyPosPrinter.set_DeviceEnabled(Boolean value)

at MyOPOSPrinterTest.frmPOSTest.Form1_Load(Object sender, EventArgs e) ...

ErrorCode: Failure

ErrorCodeExtended: 0

End of Additional Details

I'd appreciate some suggestions on what I might be missing.

 

 

 

1 Answer Found

 

Answer 1

I've also done quite a bit of searching on the MSDN Forums.
 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter