我正在使用USBHIDDRIVER来访问连接到我们本地工作站的秤。 当我在Visual Studio 2012调试中运行WCF时,一切正常。 但是,一旦我尝试在IIS中运行该服务,它似乎就无法识别USBHIDDRIVER。 我在WCF中有一个测试服务,该服务可以正常工作,因此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; }
}
}
}
为了解决该问题,我必须打开网站的“启用32位应用程序”。 相信问题与使用的DLL有关,但USBHIDDRIVER