1

USBHIDDRIVER を使用して、ローカル ワークステーションに接続された体重計にアクセスしています。Visual Studio 2012 Debug で WCF を実行すると、すべて正常に動作します。しかし、IIS でサービスを実行しようとすると、USBHIDDRIVER が認識されないようです。WCF に正常に動作するテスト サービスがあるため、WCF は動作しています。

これをトラブルシューティングする方法に関する情報は非常に役立ちます。私の問題は、IIS サーバーに展開するときに WCF がコンパイルされるため、トラブルシューティングに苦労していることです。

USBHIDRIVER に関する追加情報は次のとおりです: 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; }
        }
    }
}
4

1 に答える 1

0

この問題を解決するには、Web サイトで [32 ビット アプリケーションを有効にする] をオンにする必要がありました。問題は使用されている DLL に関連していると思われますが、USBHIDDRIVER

于 2015-06-05T17:46:42.907 に答える