How to open RJ11 cash drawer in wpf c# using .net 7 framework?

Jenish Patel 0 Reputation points
			public static PosExplorer posExplorer = new PosExplorer();
 			DeviceCollection deviceCollection = Global.posExplorer.GetDevices("CashDrawer");
            CashDrawer cashDrawer;

            foreach (DeviceInfo deviceInfo in deviceCollection)
                cashDrawer = Global.posExplorer.CreateInstance(deviceInfo) as CashDrawer;
                cashDrawer.DeviceEnabled = true;
                cashDrawer.DeviceEnabled = false;

I need to open a cash drawer in my WPF application, and I have used POSforDotNet V1.14.1 and it is working fine, but it is only supported in 4.5 framework. My application is currently being used in .net 7. How can I achieve it with different library?

Microsoft Technologies based on the .NET software framework.
2,067 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,481 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,020 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. niloufar kianfar 0 Reputation points

    hey try this code but first make sure your cash drawer connects through a USB port, serial (COM) port.

    using System.IO.Ports;
    // ...
    private void OpenCashDrawer(string comPort)
            SerialPort serialPort = new SerialPort(comPort, 9600); // Adjust if needed
            serialPort.Write("\x07"); // This tells the drawer to open
        catch (Exception ex)
            // Handle any issues that might come up

  2. Castorix31 77,506 Reputation points

    You can use CashDrawer Class

    with the package Microsoft.Windows.CsWinRT

    In Project file,

    Change TargetFramework with a recent Windows 10 SDK version (that you must have installed), like


    and add the Namespaces you want to use, like :