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


I was creating some educational material on ASP.NET 3.5 SP1, and in the process I was creating an ADO.NET Data Service, which was located in a subfolder of the Web site root folder. So, using Visual Studio 2008 SP1, I simply added this Data Service to the subfolder and added the few bits of code to be able to test it. Then I got this dreaded error message:

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

Hmm, I had seen that type of error messages before with WCF services, and since ADO.NET Data Service is wrapped as WCF services, it seemed a very similar problem to what I had previously encountered. It turns that when you ask VS 2008 SP1 to create an ADO.NET Data Service in a subfolder of an ASP.NET Web Site, it automatically creates an App_Code folder in the subfolder and adds the code-behind file to that App_Code folder and not the one in the Web site root folder. I obviously should have noticed this, but I didn’t so I did spend a good few minutes trying other “remedies” to fix the problem, until it dawned on me; Move the bloody code-behind file to App_Code folder in the Web Site root folder, and you’re good to go.

Advertisements