Answered by:
Type provided as the service attribute could not be found

Question
-
I'm attempting to create a data service using VS 2008 sp1 and .NET 3.5 sp1 as part of an asp.net application. I have other WCF services in the app and can view them in the browser just fine.
My .svc file looks like this:
<%@ ServiceHost Language="C#" Factory="System.Data.Services.DataServiceHostFactory, System.Data.Services, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Service="Jbs.TitleIVE.TrackerWeb.Services.AnotherTestDataService" %>
And the code behind looks like this:
public class AnotherTestDataService : DataService< AnotherTestModelEntities >
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(IDataServiceConfiguration config)
{
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
// config.SetEntitySetAccessRule("MyEntityset", EntitySetRights.AllRead);
// config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
}
}
When I attempt to view the service in the browser here's the result:
Server Error in '/TrackerWeb' Application.
The type 'TrackerWeb.Services.AnotherTestDataService', provided as the Service attribute value in the ServiceHost directive could not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The type 'TrackerWeb.Services.AnotherTestDataService', provided as the Service attribute value in the ServiceHost directive could not be found.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The type 'TrackerWeb.Services.AnotherTestDataService', provided as the Service attribute value in the ServiceHost directive could not be found.] System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +4072062 System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +11656092 System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +42 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479 [ServiceActivationException: The service '/TrackerWeb/Services/AnotherTestDataService.svc' cannot be activated due to an exception during compilation. The exception message is: The type 'TrackerWeb.Services.AnotherTestDataService', provided as the Service attribute value in the ServiceHost directive could not be found..] System.ServiceModel.AsyncResult.End(IAsyncResult result) +11527290 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176 System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context) +23 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
I'm having a hard time tracking down what could be wrong. How might I approach debugging this problem?
Thanks!
JamesFriday, October 3, 2008 7:12 PM
Answers
-
Quick update for anyone else with this problem. I was unable to figure out what was causing this error, so I took the (not so
easy way out and just created a new solution/projects and copied over my existing classes. Everything seems to work fine now. I still suspect that solutions created with sl2b2 and upgraded to sp1/sl2rc0 will have data services broken.
- Marked as answer by Phani Raju MSFTModerator Wednesday, May 6, 2009 6:02 PM
Monday, October 6, 2008 8:04 PM
All replies
-
Hi ,
I'd start with deleting the contents of Temporary Asp.Net files in this folder
At the command Prompt ,
IISreset /stop
navigate to %windir%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
delete all the files here
At the command Prompt ,
IISreset /start
Friday, October 3, 2008 8:08 PMModerator -
Thanks for the reply Phani. I tried the above and it didn't resolve the problem (I am using IIS to host by the way). Here are a few things I tried to attempt to narrow down the problem:
1. Created a new asp.net web app, new entity model backed by northwind and a new data service. Viewed the service in the browser using the cassini and it worked fine.
2. Then added a model and service for my "tracker" database and viewed in browser, this also worked.
3. Opened my problem solution and added the northwind entity and service; attempted to view in browser and it fails with same error.
4. Switched my problem solution over to cassini and attempted to view in browser; same error.
A little about my machine - I've been working on a SL2 b2 app for awhile. I upgraded to VS 2008 SP1 which broke astoria, so i used the interim build for the silverlight client that was posted on the web a couple of weeks ago. I recently upgraded to SL2 RC0.
Also, my problem solution was originally created on a pre-SP1 copy of VS 2008 using the sl2 b2 tools/sdk. I wonder if assembly references could be part of the problem.
Thanks again!
JamesSaturday, October 4, 2008 7:19 PM -
Quick update for anyone else with this problem. I was unable to figure out what was causing this error, so I took the (not so
easy way out and just created a new solution/projects and copied over my existing classes. Everything seems to work fine now. I still suspect that solutions created with sl2b2 and upgraded to sp1/sl2rc0 will have data services broken.
- Marked as answer by Phani Raju MSFTModerator Wednesday, May 6, 2009 6:02 PM
Monday, October 6, 2008 8:04 PM -
Hey just build ur application (both silverlight and web project)...it vl work...
- Proposed as answer by David Withers Tuesday, June 7, 2011 8:41 PM
Thursday, October 15, 2009 7:37 AM -
I got the same error.
I tried a lot of methods but did not work
I fixed using Create a new solution and add this project to the solution.
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF ForumMonday, February 1, 2010 9:53 AM -
hav faced the same issue before. it happen only where the interface and class file missing. so better check, you still have .cs files of .svc ?Monday, July 26, 2010 7:21 AM