Hi @Lasitha Lankajeewa , Welcome to Microsoft Q&A,
The following is the official example given by the official:
The following code example demonstrates how to create an instance of PosExplorer, connect to Plug and Play events, and use it to identify all connected Magnetic Stripe Reader (MSR) devices. The code example prints information about the MSR to the console and closes the device after it has finished.
// Creates a new instance of an MSR.
void CreateMsr(DeviceInfo msrinfo)
{
msr = (Msr)explorer.CreateInstance(msrinfo);
msr.Open();
msr.Claim(1000);
msr.DeviceEnabled = true;
}
static void Main(string[] args)
{
// Create a new instance of PosExplorer and use it to
// collect device information.
PosExplorer explorer = new PosExplorer();
DeviceCollection devices = explorer.GetDevices();
// Search all connected devices for an MSR, print its service
// object name to the console, and close it when finished.
foreach (DeviceInfo device in devices)
{
if (device.Type == DeviceType.Msr)
{
if (device.ServiceObjectName == currentMsr)
{
CreateMsr(device);
Console.WriteLine(device.ServiceObjectName);
// It is important that applications close all open
// Service Objects before terminating.
msr.Close();
msr = null;
}
}
}
}
Although you mention that the Microsoft Point of Sale .NET 1.14.1 runtime is installed, make sure it is installed correctly and is compatible with your application.
Make sure your project references the correct versions of Microsoft.Pos.Common.dll and Microsoft.PointOfService.dll and that these files are found and loaded correctly . Make sure your application has sufficient permissions to access the POS device. Sometimes, insufficient permissions can cause similar problems.
Make sure your cash drawer is properly connected to the computer and is being recognized properly.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.