请检查以下代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using iTimeService.dsitimeTableAdapters;
using System.IO;
namespace iTimeService
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
public zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
private bool bIsConnected = false;//the boolean value identifies whether the device is connected
private int iMachineNumber = 1;//the serial number of the device.After connecting the device ,this value will be changed.
TENTERTableAdapter tenteradapter = new TENTERTableAdapter();
T012_GATETableAdapter gateadapter = new T012_GATETableAdapter();
}
}
我在zkemkeeper.CZKEMClass
的对象创建时收到错误,其中显示:interop type 'zkemkeeper.CZKEMClass' cannot be embedded. Use the application interface instead.
答案 0 :(得分:14)
点击您所拥有的参考资料,我认为该特定项目将是' zkemkeeper'
然后在其属性上设置“嵌入互操作类型”'错误'错误' 我希望这会有所帮助。
答案 1 :(得分:0)
好的,谢谢!
private MayChamCongBLL _mayChamCongBLL = new MayChamCongBLL();
private MayChamCongDTO _mayChamCongDTO = new MayChamCongDTO();
// private System.Configuration.Configuration _ngonNgu = ConfigurationManager.OpenExeConfiguration("MitaAttendance.exe");
private int a;
private ArrayList arrMayChamCong = new ArrayList();
//public CZKEM axCZKEM1 = new CZKEM();
public zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
private int b;
// private Bar bar1;
private bool bIsConnected = false;
private int c;
private string sMaMayChamCong;
private string sSuDungWeb;
private int iMachineNumber = 1;
private int iNgonNgu;
答案 2 :(得分:0)
private CZKEMClass axCZKEM1 = new CZKEMClass();
private static bool _bIsConnected = false;
private static int _iMachineNumber = 1;
private static int _errorCode = 0;
public bool GetConnectState()
{
return _bIsConnected;
}
private void SetConnectState(bool state)
{
_bIsConnected = state;
}
private int GetMachineNumber()
{
return _iMachineNumber;
}
public int sta_ConnectTCP(string ip, string port, string commKey)
{
if (ip == "" || port == "" || commKey == "")
{
return -1;// ip or port is null
}
if (Convert.ToInt32(port) <= 0 || Convert.ToInt32(port) > 65535)
{
return -1;
}
if (Convert.ToInt32(commKey) < 0 || Convert.ToInt32(commKey) > 999999)
{
return -1;
}
int idwErrorCode = 0;
axCZKEM1.SetCommPassword(Convert.ToInt32(commKey));
if (_bIsConnected)
{
axCZKEM1.Disconnect();
SetConnectState(false);
return -2; //disconnect
}
if (axCZKEM1.Connect_Net(ip, Convert.ToInt32(port)))
{
SetConnectState(true);
return 1;
}
else
{
axCZKEM1.GetLastError(ref idwErrorCode);
return idwErrorCode;
}
}
public void sta_DisConnect()
{
if (GetConnectState())
{
axCZKEM1.Disconnect();
}
}
public int sta_ReadNewAttLog(DataTable dt_log)
{
if (GetConnectState() == false)
{
//Please connect first!";
return -1024;
}
int ret = 0;
axCZKEM1.EnableDevice(GetMachineNumber(), false);//disable the device
string sdwEnrollNumber = "";
int idwVerifyMode = 0;
int idwInOutMode = 0;
int idwYear = 0;
int idwMonth = 0;
int idwDay = 0;
int idwHour = 0;
int idwMinute = 0;
int idwSecond = 0;
int idwWorkcode = 0;
if (axCZKEM1.ReadNewGLogData(GetMachineNumber()))
{
while (axCZKEM1.SSR_GetGeneralLogData(GetMachineNumber(), out sdwEnrollNumber, out idwVerifyMode,
out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))//get records from the memory
{
DataRow dr = dt_log.NewRow();
dr["User ID"] = sdwEnrollNumber;
dr["Verify Date"] = idwYear + "-" + idwMonth + "-" + idwDay + " " + idwHour + ":" + idwMinute + ":" + idwSecond;
dr["idwYear"] = idwYear;
dr["idwMonth"] = idwMonth;
dr["idwDay"] = idwDay;
dr["idwHour"] = idwHour;
dr["idwMinute"] = idwMinute;
dr["idwSecond"] = idwSecond;
dr["Verify Type"] = idwVerifyMode;
dr["Verify State"] = idwInOutMode;
dr["WorkCode"] = idwWorkcode;
dt_log.Rows.Add(dr);
}
ret = 1;
}
else
{
axCZKEM1.GetLastError(ref _errorCode);
ret = _errorCode;
if (_errorCode != 0)
{
//"*Read attlog by period failed,ErrorCode: " + idwErrorCode.ToString();
}
else
{
//"No data from terminal returns!";
}
}
//lblOutputInfo.Items.Add("[func ReadNewGLogData]Temporarily unsupported");
axCZKEM1.EnableDevice(GetMachineNumber(), true);//enable the device
return ret;
}