10/01/2009

The type provided as the Service attribute value in the ServiceHost directive could not be found.

My WCF service on my dev server broke today after a build for seemingly no reason and the only thing it had to say for itself was "The type 'xxxxx', provided as the Service attribute value in the ServiceHost directive could not be found." I spent several hours permuting through the various changes I made earlier in the day trying to get the darn thing to work again until I exhausted nearly all possible combinations.

Puzzled and on the brink of insanity, I decided to go into IIS and see if my Authentication settings have changed. Sure enough, my ASP.NET Impersonation that my WCF service required was somehow turned off.



With the flick of a switch, everything started working again. I can only presume that the error was being caused because of a bad reference that crops up when turning off Impersonation. Sigh... If my employer only knew what I do all day...

UPDATE:

I turns out that my web.config was the culprit.  If impersonation is not enabled in web.config then it resets it in IIS each time you build out to the server.  This is the required code:
<system.web>
    <identity impersonate="true" userName="" password=""/>
</system.web>