首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到WCF REST Webinvoke

找不到WCF REST Webinvoke
EN

Stack Overflow用户
提问于 2011-04-25 20:37:52
回答 1查看 26.1K关注 0票数 17

以下是我在测试应用中使用的代码:

代码语言:javascript
复制
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的编译错误。有没有同样的想法??

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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客户端配置文件。

票数 38
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5778388

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档