Search code examples
web-servicessvc

Svc aspNetCompatibilityEnabled="true" is causing ServiceActivationException


I have a series of svc files within a web application, they all worked fine but I have a need to run with aspNetCompatibilityEnabled set to true and now I get the following exception

System.ServiceModel.ServiceActivationException: The requested service, '...' could not be activated. See the server's diagnostic trace logs for more information.

Where are these trace logs that it talks about and what could be causing this?

Thanks


Solution

  • So when turning aspNetCompatibilityEnabled to true, you need to apply changes in a couple of places. Firstly, i'm guessing you've done it in your web.config file. Secondly, you'll need to apply changes to services by decorating the service classes with AspNetCompatibilityRequirements attributes:

    C#

    [AspNetCompatibilityRequirements(
        RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class MySampleService
    {
    
    }
    

    VB

    <Activation.AspNetCompatibilityRequirements( _
    RequirementsMode:=Activation.AspNetCompatibilityRequirementsMode.Allowed)> _
    public class MySampleService 
    
    End Class
    

    You can, if all services allow it, decorate a base service class with this attribute so it's inherited by all services by default.