silverlight wcf 与 ria 的配置问题

当 aspNetCompatibilityEnabled="true" 时,sl无法引用 wcf 的服务,

wcf的 servics.svc 的文件浏览时,提示出错,如下:

The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. 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'.

当aspNetCompatibilityEnabled="false"时,试运行时,又出现出错信息:

An unhandled exception('Unhandled Error in Silverlight Application

Code:4004

Category:ManagedRuntimeError

Message:

System.ServiceModel.DomainServices.Client.DomainOperationException:

该项目中,包括wcf服务和ria服务,请问该怎么办?

 

解决方法:

首先在web.config种设置aspNetCompatibilityEnabled="true"

其次,在wcf service类上标记如下attribute

 

using System.ServiceModel.Activation;

 

    [AspNetCompatibilityRequirements(
        RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]

    public class Service2 : ClassLibrary1.IService2
    {
        ...

 

 

你可能感兴趣的:(silverlight)