Fix: WCF - The type provided as the Service attribute value in the ServiceHost directive could not be found

I wanted to expose some raw data to users in my current ASP.NET 3.5 web site project. I created a subdirectory called ‘datafeeds’ and added a WCF Data Service. I wired the dataservice up to the Entity Framework class and, on running the ItemDataService.svc file, was greeted with:

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

So why couldn’t it find the class? It was right there in the… oops!

Instead of putting the ItemDataService.vb codebehind file in the App_Code folder, VS 2010 had created a new App_Code folder under the datafeeds folder.

The fix was to drag ItemDataService.vb from the incorrect App_Code folder and drop it into the higher App_Code folder where the ASP.NET compiler knows to look for such files.

Sheesh! Why do I lose time with these silly things?

Ken

2 Comments

  • oh thank you so much.
    I spent hours trying to fix what's wrong with my WCF data service.

    And it turns out to be something simple as that.

  • Hi Ken,

    What about when you don't have an App_Code directory? I am getting this error in my web app. I am building in the project style rather than the web site model so everything is (supposed to be) compiled into the bin directory...

Comments have been disabled for this content.