Dot-Net
未找到 WCF REST Webinvoke
以下是我在測試應用程序中使用的程式碼:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using System.ServiceModel.Description; using System.IO; namespace MyWCFServices { [ServiceContract] interface IHelloWorldService { [OperationContract] String GetMessage(String name); //[OperationContract] //[WebInvoke(Method = "PUT",UriTemplate = "File/{fileName}")] //[WebContentType("application/octet-stream")] // bool UploadFile(string fileName, Stream fileContents); [OperationContract] [WebInvoke(UriTemplate = "UploadFile/{fileName}")] void UploadFile(string fileName, Stream fileContent); } }它在編譯 webinvoke 時給出和錯誤。有什麼相同的想法嗎?
WebInvokeAttribute在單獨的程序集 System.ServiceModel.Web.dll 中。你引用了那個程序集嗎?您還必須添加using System.ServiceModel.Web;編輯:
要使用 System.ServiceModel.Web.dll 程序集,您必須至少使用 .NET 3.5,並且不能使用 .NET 4.0 客戶端配置文件。