您的位置:首页 > 编程语言 > ASP

WCF 无法激活服务,由于它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性

2017-06-23 08:45 519 查看
作者:jiankunking 出处:http://blog.csdn.net/jiankunking

错误信息:

无法激活服务。由于它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性。请在 web.config 中关闭 ASP.NET 兼容性模式,或将 AspNetCompatibilityRequirements 特性加入到服务类型且同一时候将 RequirementsMode 设置为“Allowed”或“Required”。
说明: 运行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的具体信息。

异常具体信息: System.InvalidOperationException: 无法激活服务,由于它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性。

请在 web.config 中关闭 ASP.NET 兼容性模式,或将 AspNetCompatibilityRequirements 特性加入到服务类型且同一时候将 RequirementsMode 设置为“Allowed”或“Required”。

源错误:

运行当前 Web 请求期间生成了未经处理的异常。

能够使用以下的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪:

[InvalidOperationException: 无法激活服务,由于它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性。请在 web.config 中关闭 ASP.NET 兼容性模式,或将 AspNetCompatibilityRequirements 特性加入到服务类型且同一时候将 RequirementsMode 设置为“Allowed”或“Required”。

]
System.ServiceModel.Activation.HostedAspNetEnvironment.ValidateCompatibilityRequirements(AspNetCompatibilityRequirementsMode compatibilityMode) +184808
System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost) +391
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +306
System.ServiceModel.ServiceHostBase.InitializeRuntime() +82
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +64
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +789
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +287
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1132

[ServiceActivationException: 由于编译过程中出现异常。无法激活服务“/AMACTEST/RightManagementServer.svc”。异常消息为: 无法激活服务,由于它不支持 ASP.NET 兼容性。

已为此应用程序启用了 ASP.NET 兼容性。

请在 web.config 中关闭 ASP.NET 兼容性模式,或将 AspNetCompatibilityRequirements 特性加入到服务类型且同一时候将 RequirementsMode 设置为“Allowed”或“Required”。。]
System.Runtime.AsyncResult.End(IAsyncResult result) +890624
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +180062
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +136

解决方式:

1、改动对应服务.svc.cs,在类上加入以下标识

using System.ServiceModel.Activation ;
[AspNetCompatibilityRequirements (RequirementsMode=AspNetCompatibilityRequirementsMode.Required)]


据说:启用了AJAX的WCF服务是默认加入的

请移步到小注中的链接,谢谢

小注:

更具体的问题分析參考:

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'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: 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'.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐