辰凌风

"Forget What Made Them Successful " Trap

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

点击发现,可以发现服务,但是无法添加引用

Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'.

我使用的 vs.net 2010 

有两种解决办法:(在添加引用前,请先保证已经编译过。修改后,也需要再次编译。)

1、给服务添加上特性:

首先需要添加引用:

using System.ServiceModel.Activation
在添加特性:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

public class MyService : IMyService

2、修改web.configure文件

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />

将aspNetCompatibilityEnabled 修改为false

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />
</system.serviceModel>

posted on 2011-04-15 01:16  辰凌风  阅读(428)  评论(0编辑  收藏  举报
忒客淘-我的站