Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010, WCF Service wouldn't start

I will go through what i've done so far step by step as below:

  1. created empty solution
  2. added a website WCFService
  3. deleted the Service and IService from the website
  4. added a WCF service library project to the solution
  5. added end points to the web.config
  6. did the same in app.config
  7. added a reference to the service library in the web application
  8. ctrl + F5 9

I get the following error:

Server Error in '/WFLedger' Application. The type 'Services.WFLedger.WF_Ledger', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations 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 'Services.WFLedger.WF_API_Ledger', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations 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 'Services.WFLedger.WF_Ledger', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.]
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +654
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1439
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +45
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +647

[ServiceActivationException: The service '/WFLedger/WF_Ledger.svc' cannot be activated due to an exception during compilation. The exception message is: The type 'Services.WFAPILedger.WF_API_Ledger', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..]
System.Runtime.AsyncResult.End(IAsyncResult result) +437
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +188
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +230 System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +360
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +213 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +76

this is really driving me crazy!!! why am i getting this error? if you need more information please let me know so that i provide them to you thanks a million in advance

like image 745
LOO Avatar asked May 05 '11 11:05

LOO


5 Answers

Please check if the .svc file is provided and is of the following form.

 <% @ServiceHost Language=C# Debug="true" Service="MyService" CodeBehind="~/App_Code/Service.cs" %>

Its all one line and the file should contain nothing else.

like image 78
SaravananArumugam Avatar answered Nov 15 '22 22:11

SaravananArumugam


Try to add new default service then check newly added works fine. If yes, check web.config endpoint contract name provided, and in .svc file check code behind mentioned correctly.

like image 43
Atyulya Avatar answered Nov 15 '22 22:11

Atyulya


Look at the WF_Ledger.svc file in your web site project. It should only consist of one line. There'll be Service attribute containing "Services.WFAPILedger.WF_API_Ledger". WCF is looking for the "Services.WFAPILedger.WF_API_Ledger" class but not finding it. The namespace and class name need to either exist in the web site project or be a reference as you're trying to set up. You'll need to edit that Service attribute to match the service implementation class in the WCF service library project.

like image 21
Sixto Saez Avatar answered Nov 15 '22 21:11

Sixto Saez


In .svc file Service parameter should include namespace followed by class name i.e. it should be in the format mynamespace.myservice

like image 28
Softec Avatar answered Nov 15 '22 22:11

Softec


Build the WCF project and try again. This error may occur because of the absence of a DLL in bin folder.

For me building and trying again resolved it.

like image 36
NidhinSPradeep Avatar answered Nov 15 '22 23:11

NidhinSPradeep