This project is read-only.

AspNetCompatibilityRequirements Issues

Feb 13, 2009 at 5:03 PM
Hello, 

I'm building a Silverlight app that uses DeepEarth to display dealer locations. I have integrated the DeepEarth control and it is displaying maps. When I add a WCF Service to connect to our DB using Linq2SQL it cannot connect.

Here is the error: 
=============================================================

There was an error downloading 'http://localhost:49338/Services/GetMapLocations.svc'.
The request failed with the error message:
--
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'.

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'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.           

Stack Trace:

[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'.]
   System.ServiceModel.Activation.AspNetCompatibilityRequirementsAttribute.System.ServiceModel.Description.IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase) +11669267
   System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost) +161
   System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +84
   System.ServiceModel.ServiceHostBase.InitializeRuntime() +37
   System.ServiceModel.ServiceHostBase.OnBeginOpen() +27
   System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +49
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +121
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479

[ServiceActivationException: The service '/Services/GetMapLocations.svc' cannot be activated due to an exception during compilation.  The exception message is: 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'..]
   System.ServiceModel.AsyncResult.End(IAsyncResult result) +11531006
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176
   System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context) +23
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Version Information:
Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074

Metadata contains a reference that cannot be resolved: 'http://localhost:49338/Services/GetMapLocations.svc'.
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
If the service is defined in the current solution, try building the solution and adding the service reference again.
=============================================================

I can't disable ASP Compatibility without disabling the DeepEarth VETokenServiceBehavior.

Are there any good examples out there of how to incorporate both services simultaneously?

Here are the service definitions in the web.config file: 

 

<

 

system.serviceModel>

 

<

 

behaviors>

 

<

 

serviceBehaviors>

 

<

 

behavior name="VETokenServiceBehavior">

 

<

 

serviceMetadata httpGetEnabled="true" />

 

<

 

serviceDebug includeExceptionDetailInFaults="false" />

 

</

 

behavior>

 

<

 

behavior name="dashboard.Web.GetMapLocationsBehavior">

 

<

 

serviceMetadata httpGetEnabled="true" />

 

<

 

serviceDebug includeExceptionDetailInFaults="false" />

 

</

 

behavior>

 

</

 

serviceBehaviors>

 

</

 

behaviors>

 

<

 

serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

 

<

 

services>

 

<

 

service behaviorConfiguration="VETokenServiceBehavior" name="TokenService">

 

<

 

endpoint address="" binding="basicHttpBinding" contract="ITokenService" />

 

<

 

endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

 

</

 

service>

 

<

 

service behaviorConfiguration="dashboard.Web.GetMapLocationsBehavior"

 

 

 

 

 

name="dashboard.Web.GetMapLocations">

 

<

 

endpoint address="" binding="basicHttpBinding" contract="dashboard.Web.IGetMapLocations">

 

<

 

identity>

 

<

 

dns value="localhost" />

 

</

 

identity>

 

</

 

endpoint>

 

<

 

endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

 

</

 

service>

 

</

 

services>

 

</

 

system.serviceModel>

Feb 13, 2009 at 5:46 PM
When you added your WCF service, did you add it as a Silverlight-enabled WCF service or did you just add a regular WCF service? It sounds like you added a regular WCF service which doesn't have all of the settings quite correct for Silverlight. If you add a new Silverlight-enabled WCF service you can see the differences. The main differences is that you need the AspNetCompatiblityRequirements attribute on your service.
Feb 14, 2009 at 3:18 AM
look at token service

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class TokenService : ITokenService
    {
	......
Feb 14, 2009 at 5:10 AM
Colin is correct I added a normal WCF service. I found this tutorial very helpful: 

http://www.codeproject.com/KB/silverlight/SilverlightWcfDatabase.aspx?msg=2924381#xx2924381xx

Thank you both for the speedy responses.

J