I am new in POS system, so if I miss out any info let me know will edit with it.
I have installed a WINFORM on other PC through setup, and I want top open a cash drawer attached to it on form load. I have used Microsoft.PointOfService dll. And heres my code :
public partial class CashRegister : Form
{
CashDrawer myCashDrawer;
PosExplorer explorer;
public CashRegister()
{
InitializeComponent();
explorer = new Microsoft.PointOfService.PosExplorer();
DeviceInfo ObjDevicesInfo = explorer.GetDevice("CashDrawer", "EP-125k");
//myCashDrawer = (CashDrawer) explorer.CreateInstance(ObjDevicesInfo);
// myCashDrawer.OpenDrawer();
}
public void OpenCashDrawer()
{
myCashDrawer.Open();
myCashDrawer.Claim(1000);
myCashDrawer.DeviceEnabled = true;
myCashDrawer.OpenDrawer();
myCashDrawer.DeviceEnabled = false;
myCashDrawer.Release();
myCashDrawer.Close();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void CashRegister_Load(object sender, EventArgs e)
{
// myCashDrawer.OpenDrawer();
}
}
But when it executes it gives following error:
type initializer for 'Microsoft.PointOfService.Management.Explorer' threw an exception
Can any one help.
Thanks
EDIT : this is the TypeInitializationException error's details
`See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.TypeInitializationException: The type initializer for 'Microsoft.PointOfService.Management.Explorer' threw an exception. ---> Microsoft.PointOfService.PosLibraryException: Failed to open registry key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\POSfor.NET\ControlAssemblies.
at Microsoft.PointOfService.Management.AssemblyLoader.Scan()
at Microsoft.PointOfService.Management.AssemblyLoader.Scan()
at Microsoft.PointOfService.Management.Explorer.ScanForSOAssemblies()
at Microsoft.PointOfService.Management.Explorer.Refresh()
at Microsoft.PointOfService.Management.Explorer..ctor()
at Microsoft.PointOfService.Management.Explorer..cctor()
--- End of inner exception stack trace ---
I have fixed thanks to all of you, it was just a silly misout.nstalled POS for .Net v1.12.exe and it does not gives any error.