【发布时间】:2018-12-19 02:34:14
【问题描述】:
我正在尝试在 Web 应用程序中连接生物识别设备。我在 windows 应用程序中工作正常,但在 web 中它会抛出错误。
Windows-form.cs:
int nPort = Convert.ToInt32(textPort.Text);
int nPassword = Convert.ToInt32(textPassword.Text);
string strIP = ipAddressControl1.IPAddress.ToString();
bRet = axFP_CLOCK.SetIPAddress(ref strIP, nPort, nPassword);
if(!bRet)
{
return;
}
表单设计器:
((System.ComponentModel.ISupportInitialize)(this.axFP_CLOCK)).BeginInit();
this.axFP_CLOCK.Enabled = true;
this.axFP_CLOCK.Location = new System.Drawing.Point(476, 382);
this.axFP_CLOCK.Name = "axFP_CLOCK";
this.axFP_CLOCK.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axFP_CLOCK.OcxState")));
this.axFP_CLOCK.Size = new System.Drawing.Size(100, 50);
this.axFP_CLOCK.TabIndex = 11;
this.axFP_CLOCK.Visible = false;
((System.ComponentModel.ISupportInitialize)(this.axFP_CLOCK)).EndInit();
同样,我尝试在 Web 应用程序中连接,但它显示错误: 网络表格1:
public AxFP_CLOCKLib.AxFP_CLOCK axFP_CLOCK;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bool bRet;
string ip= "192.168.1.109";
int nPort = Convert.ToInt32(5005);
int nPassword = Convert.ToInt32(0);
axFP_CLOCK = new AxFP_CLOCKLib.AxFP_CLOCK();
bRet = axFP_CLOCK.SetIPAddress(ref ip, nPort, nPassword);
if (!bRet)
{
Response.Write("success");
}
else
{
Response.Write("failure");
}
}
}
它会抛出错误
ActiveX 控件 '87733ee1-d095-442b-a200-6de90c5c8318' 不能 实例化,因为当前线程不在单线程中 公寓。
DLL:
public virtual bool SetIPAddress(ref string lpszIPAddress, int dwPortNumber, int dwPassWord)
{
if (this.ocx == null)
throw new AxHost.InvalidActiveXStateException(nameof (SetIPAddress), AxHost.ActiveXInvokeKind.MethodInvoke);
return this.ocx.SetIPAddress(ref lpszIPAddress, dwPortNumber, dwPassWord);
}
谁能帮我纠正这个错误?
【问题讨论】:
标签: c# asp.net biometrics