How to Connect Attendance Punching Machine Using zKemKeeper in C#?

Surya picture Surya · Feb 27, 2016 · Viewed 10.7k times · Source

I am developing attendance software using asp.net c#, when iam trying to connect biometric device ( attendance punching machine ) using asp.net c# it shows the error

Error: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

My Code :

//internal Axzkemkeeper.AxCZKEM AxCZKEM1;
    //public Axzkemkeeper.AxCZKEM axCZKEM1 = new Axzkemkeeper.AxCZKEM();
    //public zkemkeeper.CZKEM axCZKEM1 = new zkemkeeper.CZKEM();
    //public delegate int DecompressMCX(int hComp,IntPtr in, uint in_len, IntPtr out, ref uint out_len, bool eod);

    public zkemkeeper.CZKEM axCZKEM1 = new zkemkeeper.CZKEM();

private void Essl_Connect(string IpAddress, int MachineNo)
    {
        try
        {
            bConn = axCZKEM1.Connect_Net(IpAddress.Trim(), 8080);
            //bConn = axCZKEM1.Connect_Net(IpAddress.Trim(), 4370);
            if (bConn == true)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('Connected')", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('Not Connected')", true);
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "Error Message", "alert('" + ex.Message.ToString() + "')", true);
        }
    }

any one rectify this problem, is there any alternative way to connect the machine?..

if iam using

public zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();

it shows the following Error:

"Interop type 'zkemkeeper.CZKEMClass' cannot be embedded. Use the applicable interface instead."

Answer

Oscar Goicochea picture Oscar Goicochea · Jul 20, 2017

Change (in properties) of that dll interop.zkemkeeper, embed type to False.