.net - 找不到WCF REST Webinvoke

标签 .net wcf rest .net-4.0 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客户端配置文件。

关于.net - 找不到WCF REST Webinvoke,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5778388/

相关文章:

c# - 从现有 API 自动生成服务器端 WCF 服务

wpf - 是否有类似于 Prism 中使用的桌面应用程序事件聚合器之类的东西?

wcf - 选择与 asp.net-mvc 一起使用的 REST 框架

REST API - 客户端如何知道发布到资源的有效负载是什么?

c# - VSIX:获取 DTE 对象

c# - .NET 垃圾收集器能否收集作为类成员的对象?

php - 对应的restful PHP函数有没有标准?

java - 使用 Java Jersey 和 MongoDB 的 RESTful API

.net - 有什么方法可以在 azure 事件中心中使用 EventProcessorHost 检索跳过的事件吗?

c# - 如何确定 .NET 中的并发 HTTP 请求瓶颈?