我使用USBHIDDRIVER访问连接到本地工作站的秤。当我在Visual Studio 2012 Debug中运行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; }
}
}
}
答案 0 :(得分:0)
为了解决这个问题,我必须为网站启用“启用32位应用程序”。相信问题与使用的DLL有关,但USBHIDDRIVER