Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
532 views
in Technique[技术] by (71.8m points)

c# - Error when inserting finger print data into database table

I am working in a project that's already built and functional at the moment. But there is an issue when I try to insert finger print from device to database table. Let me write it was working fine earlier. But when I setup a new computer or moved the project in a new environment, it throws an exception:

Retrieving the COM class factory for component with CLSID {00853A19-BD51-419B-9269-2DABE57EB61F} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

This is a fingerprint attendance system that uses ZkemKeeper and the dll file is attached with the project. Here is the code snippet:

/**This is a list of the users from database that uses fingerprint system - Starts**/
List<AttMachineBO> lstfrom = new List<AttMachineBO>();

for (int i = 0; i < dgv_Machine.Rows.Count; i++)
{
   if (dgv_Machine.Rows[i].Cells[0].Value == null)
   {
      dgv_Machine.Rows[i].Cells[0].Value = false;
   }

   if ((bool)dgv_Machine.Rows[i].Cells[0].Value == true)
   {
      AttMachineBO obj = new AttMachineBO();
      obj.Mechine_No = dgv_Machine.Rows[i].Cells[1].Value.ToString();
      obj.Machine_Name = dgv_Machine.Rows[i].Cells[2].Value.ToString();
      obj.IP_Address = dgv_Machine.Rows[i].Cells[3].Value.ToString().Trim();

      lstfrom.Add(obj);
   }
} 
/**This is a list of the users from database that uses fingerprint system - Ends**/

Basically the above code is to load user details from table assigned with an IP address and on click, the fingerprint data will be inserted into database table from attendance device (ZKTeco i-clock 580). For inserting data, the below is code is used:

if (lstfrom.Count > 0)
{
   for (int x = 0; x < lstfrom.Count; x++)
   {
       /Here the exception starts/
       **zkemkeeper.CZKEMClass fromM = new zkemkeeper.CZKEMClass();**

       lblStatus.Text = "Connect To Device " + lstfrom[x].Machine_Name + " , IP=" + lstfrom[x].IP_Address + ".....";
        lblStatus.Refresh();

            if (fromM.Connect_Net(lstfrom[x].IP_Address, 4370))
            {
                lblStatus.Text = "Register The Device To PC";
                lblStatus.Refresh();

                if (fromM.RegEvent(fromM.MachineNumber, 65535))
                {
                    lblStatus.Text = "Reading All Data From Machine";
                    lblStatus.Refresh();
                    fromM.ReadAllTemplate(fromM.MachineNumber);

                    List<AttMachineBO> datalst = new List<AttMachineBO>();

                    string empId = "", name = "", fingerprintData = "", fingerprintData2 = "", password = ""; ;
                    int prev = 0, TmpLength = 0;
                    bool isEnable = false;
                    int k = 0;

                    while (fromM.SSR_GetAllUserInfo(fromM.MachineNumber, out empId, out name, out password, out prev, out isEnable))
                    {
                        lblStatus.Text = "Processing Employee with ID=" + empId + ", Name =" + name;
                        lblStatus.Refresh();

                        AttMachineBO bo = new AttMachineBO();
                        bo.EMP_ID = empId;
                        bo.EMP_Name = name;
                        bo.IsfingerSaa = true;
                        bo.IP_Address = lstfrom[x].IP_Address;
                        bo.Com_Id = HRMS.MAIN.HRMS.Company;

                        bool f = fromM.SSR_GetUserTmpStr(fromM.MachineNumber, empId, 0, out fingerprintData, out TmpLength);
                        bo.finger1 = fingerprintData != null ? fingerprintData : "";
                        f = fromM.SSR_GetUserTmpStr(fromM.MachineNumber, empId, 1, out fingerprintData, out TmpLength);
                        bo.finger2 = fingerprintData != null ? fingerprintData : "";

                        datalst.Add(bo);
                    }

                    bool flag = Facede.Attendance.InserDatabase(datalst);

                    if (flag)
                    {
                        MessageBox.Show("Insert Successfully.");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Error In Insert.");
                        return;
                    }
                }
                else
                {
                    lblStatus.Text = "Device registration failed.";
                    lblStatus.Refresh();
                }
            }
            else
            {
                lblStatus.Text = "Failed to stablish connecting to device =" + lstfrom[x].Machine_Name + ", IP =" + lstfrom[x].IP_Address + "...."; ;
                lblStatus.Refresh();
            }
     }
} 

I've highlighted in the code (Second code section) from the exception starts and bit confused how to resolve it.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The error that you are receiving is clear, zkemkeeper.dll needs to be registered on the windows system.

I don′t know if you already have all the dll files... In case that you don′t have all the dll files you should download the latest SDK version from the following link https://www.zkteco.eu/uploads/ftp/SDK/Standalone%20SDK-Ver6.3.1.34.rar

To avoid troubleshooting, you should register the 32-bit version instead of the 64-bit and compile your application for the x86 architecture.

For registering the dll, copy the contents of the 32-bit folder into c:windowssystem (or c:windowssyswow64 if your computer is x64) and after that, open the console with admin privileges, position in the folder in which you have just copied the dll and run the following command:

regsvr32 zkemkeeper.dll

After registering the files, you need to adjust the reference to this dll. In visual studio, delete your current reference and Add a new one in the affected project. You will find the new registered dll at the bottom of the COM tab.

After adding the reference, you need to adjust one parameter. Select the reference and right-click -> properties, it will open the properties window.. Set "Embed interop types" to false.

That should work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...