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

Published Thursday, June 03, 2010 9:18 AM by Ken Cox [MVP]

Comments

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

Sunday, October 17, 2010 7:03 PM by Tentacle

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.

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

Friday, February 04, 2011 6:14 PM by Keith Barrows

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

Leave a Comment

(required) 
(required) 
(optional)
(required)