Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"service cannot be activated because it requires asp net compatibility", but I need it for impersonation

I posted a question yesterday about how to enable impersonation using WCF services here: WCF service not impersonating specified user in config?

I enabled aspnetCompatibilityMode but when I update my service proxy, it says "the service cannot be activated because it requires asp net compatibility". I'm not entirely sure what this means. If I change the setting to AspNetCompatibilityRequirementsMode.Allowed, it doesn't enable impersonation. I tried enabling the setting in both the web.config as well as via the class attribute.

Is there a way around this without setting my service's app pool to run as the user I need? Thanks.

like image 307
Ryan Peters Avatar asked Mar 03 '11 12:03

Ryan Peters


1 Answers

You must turn on AspNetCompatibility in web.config of site hosting your service:

<system.serviceModel>
  ...
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>

Because you are making your service implementation dependent on ASP.NET you should mark your service class with:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

Default value of AspNetCompatibilityRequirements.RequirementMode is NotAllowed so that is most probably reason for your exception.

like image 197
Ladislav Mrnka Avatar answered Nov 08 '22 22:11

Ladislav Mrnka