Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,

I tried to write code with C#.net for windows form POS-printing connection using OPOSPOSPritner.dll but it is failed with the error with of type casting wrong for com object to interface. I need to use the previous class and dll files for maintenance. Please help me to point out to continue working for that. I haven't found much for that POS printing sample code. Thanks in advance.

What I have tried:

using System;
using System.Data;
using System.Drawing;
using POS.Devices;

using System.Text;
using System.Windows.Forms;


namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
private OPOSPOSPrinter printer = null;

public Form1()
{
InitializeComponent();
}

private void btnPrint_Click(object sender, EventArgs e)
{

printer = new OPOSPOSPrinterClass();
printer.Open("ReceiptPrinter1");
printer.ClaimDevice(1000);
printer.DeviceEnabled = true;
printer.PrintNormal(2, "\x1B|cA\x1B|2COPOS POSPrinter\x1B|1C\nvia Microsoft.NET\n\n");
printer.Close();
}
}
}
Posted
Updated 6-Mar-17 3:40am
Comments
[no name] 6-Mar-17 7:32am    
What did the documentation tell you when you read it? What did the technical support people tell you when you asked them?
ZurdoDev 6-Mar-17 8:03am    
You're using a very specific device and control. It's not likely you'll find someone who has done the same thing here. I suggest you read the docs and contact support.
Richard MacCutchan 6-Mar-17 8:07am    
Where does the error occur and what is the exact message.

1 solution

Hey,
Your question is really specified for a specific device but I think the following steps can help you to overcome this problem. However, following steps are not a solution but they are a right method to finding out possibly solutions.

First of all, make sure that you have followed the right implementation which purposed by device vendor.
Second, try to read this link and understand the concept of OPOS for .Net as it has some good hints.
Third, use faile and try method and F7 or F11 and make sure everything is executing in a right way. For example:

C#
printer = new OPOSPOSPrinterClass(); //Make sure you don`t need to initialize anything and check overloaded constructors
printer.Open("ReceiptPrinter1"); // Check your printer class after executing this line and make sure there is no fault on the instantiated class (printer)
printer.ClaimDevice(1000); //Is it enought to pool your device
printer.DeviceEnabled = true;
printer.PrintNormal(2, "\x1B|cA\x1B|2COPOS POSPrinter\x1B|1C\nvia Microsoft.NET\n\n");//Make sure about this line seems to be tricky
printer.Close();


At the end do not forget to add try{} catch{} body to your code.
Btw, if none of the above steps did not help you to solve your problem do not hesitate to drop and email to
Curtiss Monroe
crmonroe@monroecs.com
.
Good luck
A.H.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900