USBHIDDRIVER 在 Visual Studio 调试模式下工作,但在部署到 IIS 时不工作
USBHIDDRIVER works in Visual Studio debug mode but not when deployed to IIS
我正在使用 USBHIDDRIVER 访问连接到本地工作站的体重秤。当我在 Visual Studio 2012 调试中 运行 WCF 时一切正常。但是一旦我尝试 运行 IIS 中的服务,它似乎无法识别 USBHIDDRIVER。我在 WCF 中有一个测试服务,它工作正常,所以 WCF 正在工作。
有关如何解决此问题的任何信息都将非常有帮助。我的问题是当我部署到 IIS 服务器时编译了 WCF,所以我很难尝试排除故障。
这里是关于 USBHIDDRIVER 的附加信息:http://www.florian-leitner.de/index.php/projects/usb-hid-driver-library/
namespace USBDevices
{
public class Service1 : IService1
{
public string GetWeight(string id)
{
USBHIDDRIVER.USBInterface usb = new USBHIDDRIVER.USBInterface("vid_0922","pid_8007");
//string[] list = usb.getDeviceList();
string result;
string resultDesc;
byte itemWeight;
byte itemUOM;
result = "";
resultDesc = "";
itemWeight = 0;
itemUOM = 0;
if (usb.Connect() == true)
{
usb.startRead();
Thread.Sleep(100);
for (int i = 0; i < 200; i++)
{
var weight = USBHIDDRIVER.USBInterface.usbBuffer;
var cnt = weight.Count;
itemWeight = ((byte[])weight[cnt - 1])[4];
itemUOM = ((byte[])weight[cnt - 1])[2];
}
usb.stopRead();
result = "Success";
resultDesc = "Scale Found";
Debug.WriteLine("Result: " + result + "-" + resultDesc + " - Item Weight: " + ((float)itemWeight / 10));
}
else
{
result = "Failed";
resultDesc = "Scale Not Active";
itemWeight = 0;
itemUOM = 0;
Debug.WriteLine("Result: " + result + "-" + resultDesc + " - Item Weight: " + ((float)itemWeight / 10));
}
return result + "|" + resultDesc + "|" + ((float)itemWeight / 10) + "|" + itemUOM;
}
public string XMLData(string id)
{
return "You requested product " + id;
}
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
}
为了解决这个问题,我不得不为网站打开 "Enable 32-Bit Applications"。相信问题与使用的 DLL 有关,但 USBHIDDRIVER
我正在使用 USBHIDDRIVER 访问连接到本地工作站的体重秤。当我在 Visual Studio 2012 调试中 运行 WCF 时一切正常。但是一旦我尝试 运行 IIS 中的服务,它似乎无法识别 USBHIDDRIVER。我在 WCF 中有一个测试服务,它工作正常,所以 WCF 正在工作。
有关如何解决此问题的任何信息都将非常有帮助。我的问题是当我部署到 IIS 服务器时编译了 WCF,所以我很难尝试排除故障。
这里是关于 USBHIDDRIVER 的附加信息:http://www.florian-leitner.de/index.php/projects/usb-hid-driver-library/
namespace USBDevices
{
public class Service1 : IService1
{
public string GetWeight(string id)
{
USBHIDDRIVER.USBInterface usb = new USBHIDDRIVER.USBInterface("vid_0922","pid_8007");
//string[] list = usb.getDeviceList();
string result;
string resultDesc;
byte itemWeight;
byte itemUOM;
result = "";
resultDesc = "";
itemWeight = 0;
itemUOM = 0;
if (usb.Connect() == true)
{
usb.startRead();
Thread.Sleep(100);
for (int i = 0; i < 200; i++)
{
var weight = USBHIDDRIVER.USBInterface.usbBuffer;
var cnt = weight.Count;
itemWeight = ((byte[])weight[cnt - 1])[4];
itemUOM = ((byte[])weight[cnt - 1])[2];
}
usb.stopRead();
result = "Success";
resultDesc = "Scale Found";
Debug.WriteLine("Result: " + result + "-" + resultDesc + " - Item Weight: " + ((float)itemWeight / 10));
}
else
{
result = "Failed";
resultDesc = "Scale Not Active";
itemWeight = 0;
itemUOM = 0;
Debug.WriteLine("Result: " + result + "-" + resultDesc + " - Item Weight: " + ((float)itemWeight / 10));
}
return result + "|" + resultDesc + "|" + ((float)itemWeight / 10) + "|" + itemUOM;
}
public string XMLData(string id)
{
return "You requested product " + id;
}
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
}
为了解决这个问题,我不得不为网站打开 "Enable 32-Bit Applications"。相信问题与使用的 DLL 有关,但 USBHIDDRIVER