我想使用 C# 连接生物识别机器。我正在使用 zkemkeeper dll 连接机器
我已经使用 connect_net 方法连接了 ip 地址和端口
public partial class Form1 : Form
{
public zkemkeeper.CZKEM machineObj = new zkemkeeper.CZKEM();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
bool status = false;
status = machineObj.Connect_Net("10.10.32.162", 5005);
if (status)
{
MessageBox.Show("Connect to machine successfully");
}
}
}
现在这个 machineObj.Connect_Net 总是返回 false 这背后的原因是什么,有人有解决方案吗?
错误代码为-2
最佳答案
很久以前处理的时候,在这个post里面发现了一些代码工程的有用tips :
1) The connection is denied by firewall settings (on your system or a router): Check the firewall logs.
2) The device has a white or black list configuration that does not allow connections from your system's IP address: Check the configuration of the device and the log files (if such exist).
3) The packages are not routed when your system is not in the same subnet as the device: Configure port forwarding on the device's next gateway.
如果您的设备是白名单或黑名单配置,您最好开始深入研究您的日志和设备配置。
同时开始探索您的防火墙,如果有的话,确保您没有被阻止连接到设备。
编辑:我看到了您的评论,所以这可能是您遇到问题的原因。
然而,最常见的原因是第三个,因为它更容易错过,不引人注意且不引人注目。 确保您的系统与设备位于同一子网中。如果没有,请在设备上配置您的端口转发。
关于c# - 使用 C# 连接生物识别机器时返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51472287/