无法激活服务,因为它不支持 ASP.NET 兼容性

Coordinator
Sep 21, 2011 at 2:13 AM
以下是报错信息:
无法激活服务,因为它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性。请在 web.config 中关闭 ASP.NET 兼容性模式或将 AspNetCompatibilityRequirements 属性添加到服务类型且同时将 RequirementsMode 设置为“Allowed”或“Required”。

 

如果有以下配置节,或者取消下面这段

<serviceHostingEnvironment aspNetCompatibilityEnabled="true"

      multipleSiteBindingsEnabled="true" />

需要加入这段代码:

using System.ServiceModel.Activation;

 

 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

public class MovieService : ImovieService{}

 

 

配置WCF其中一节,配置文件如下

<system.serviceModel>

 

    <services>

      <service name="SilverlightApplication1.Web.MovieService" behaviorConfiguration="MovieServiceBehaviors" >

        <endpoint address="" binding="basicHttpBinding" contract="SilverlightApplication1.Web.IMovieService"></endpoint>

      </service>

    </services>

 

    <behaviors>

      <serviceBehaviors>

        <behavior name="MovieServiceBehaviors" >

          <serviceMetadata httpGetEnabled="true" />

        </behavior>

      </serviceBehaviors>

    </behaviors>

 

  </system.serviceModel>