将指纹数据插入数据库表时出错

AT-*_*017 2 c# dll device zkemkeeper

我正在从事一个目前已经建成并投入运行的项目。但是当我尝试将指纹从设备插入数据库表时出现问题。让我写一下它之前运行良好。但是当我设置新计算机或将项目移动到新环境中时,它会抛出异常:

由于以下错误,检索 CLSID 为 {00853A19-BD51-419B-9269-2DABE57EB61F} 的组件的 COM 类工厂失败:80040154 类未注册(HRESULT 异常:0x80040154 (REGDB_E_CLASSNOTREG))。

这是一个使用ZkemKeeper的指纹考勤系统,dll文件随项目一起附上。这是代码片段:

/**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**/
Run Code Online (Sandbox Code Playgroud)

基本上,上面的代码是从分配有 IP 地址的表中加载用户详细信息,然后单击,指纹数据将从考勤设备(ZKTeco i-clock 580)插入到数据库表中。为了插入数据,使用以下代码:

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();
            }
     }
} 
Run Code Online (Sandbox Code Playgroud)

我在代码(第二个代码部分)中突出显示了异常开始的部分,并且对如何解决它感到有点困惑。

Rob*_*uez 6

您收到的错误很明显,zkemkeeper.dll 需要在 Windows 系统上注册。

\n\n

我不\xc2\xb4t 知道你是否已经拥有所有 dll 文件...如果你没有 \xc2\xb4t 拥有所有 dll 文件,你应该从以下链接下载最新的 SDK 版本https://www.zkteco .eu/uploads/ftp/SDK/Standalone%20SDK-Ver6.3.1.34.rar

\n\n

为了避免出现故障,您应该注册 32 位版本而不是 64 位版本,并针对 x86 架构编译应用程序。

\n\n

要注册 dll,请将 32 位文件夹的内容复制到 c:\\windows\\system(如果您的计算机是 x64,则复制到 c:\\windows\\syswow64),然后使用管理员权限打开控制台,找到刚刚复制的dll所在的文件夹并运行以下命令:

\n\n
regsvr32 zkemkeeper.dll\n
Run Code Online (Sandbox Code Playgroud)\n\n

注册文件后,您需要调整对此dll的引用。\n在 Visual Studio 中,删除当前引用并在受影响的项目中添加新引用。您将在 COM 选项卡的底部找到新注册的 dll。

\n\n

添加参考后,需要调整一项参数。选择引用并右键单击 -> 属性,它将打开属性窗口。将“嵌入互操作类型”设置为 false。

\n\n

那应该有效。

\n