<system.serviceModel> ... . <servicehostingenvironment aspnetcompatibilityenabled= "true" multiplesitebindingsenabled= "true"/> </system.serviceModel>
If the configuration of aspnetcompatibilityenabled such as in WCF configuration, the corresponding ServiceContract implementation class is also added to the corresponding declaration, as follows:
[ServiceContract]Interfaceimycontract {[OperationContract]stringMyMethod (stringtext); [OperationContract]stringMyothermethod (stringtext); }[Aspnetcompatibilityrequirements (Requirementsmode = aspnetcompatibilityrequirementsmode.required)] Public classMyservice:imycontract { Public stringMyMethod (stringtext) { return string. Format ("hello,{0}", text); } Public stringMyothermethod (stringtext) { return string. Format ("cannot call this method over wcf,{0}", text); } }
VS, when creating a WCF service, the compatibility mode is added, and if a declaration of compatibility mode is missing when the contract is implemented, an error occurs.
The service cannot be activated because it requires ASP. ASP. NET compatibility is not enabled for this application. Either enable ASP. NET compatibility in Web. config, or set the Aspnetcompatibilityrequirementsattribute.aspnetcompatibilityrequirementsmode property to A value other than Required.
Example of compatibility mode usage: http://www.cnblogs.com/artech/archive/2009/06/25/1511165.html
WCF cannot activate the service because it does not support ASP.