
Release the device handle when closing the form Protected override void OnFormClosing(FormClosingEventArgs e) TextBox1.Text = "Failed to connect to MSR605X\r\n" Private void Form1_Load(object sender, EventArgs e) The program is able to detect the writer properly when it is connected via USB, and the MSRX program works perfectly. MessageBox.Show("Access violation error: " + ex.Message) Handle = MSR_InitComm(vendorId, productId) Ĭatch (System.AccessViolationException ex) Neither of these sources gave any clarity on the -36 response code or why the InitComm will not work.Įven when catching the exception with the following code, the program still crashes and never gets to the MessageBox. I have tried reading the documentation at 's%20Manual.pdf, I have tried googling the problem (but it is very niche), and I have even tried with ChatGPT. MSR_InitComm returns a value of -36 instead of the expected 0. When trying to initialize communication to the device, using MSR_InitComm(productId, vendorId), I am getting the SystemAccessViolation exception. It came with a MagAPI.dll, which I used Dependency Walker to view the function names.

It works perfectly, but as a coding project, I wanted to do a clone of it. I'm currently trying to write a Windows Forms Application that can read/write magstripe card data with the Deftun MSR605X.
