以下是我在测试应用中使用的代码:
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的编译错误。有没有同样的想法??
发布于 2011-04-25 20:39:59
WebInvokeAttribute位于单独的程序集System.ServiceModel.Web.dll中。您是否引用了该程序集?此外,您还必须添加using System.ServiceModel.Web;
编辑:
要使用System.ServiceModel.Web.dll程序集,您必须至少使用.NET 3.5,并且不能使用.NET 4.0客户端配置文件。
https://stackoverflow.com/questions/5778388
复制相似问题