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.