VS2010,WCF服务无法启动

LOO*_*LOO 12 wcf visual-studio-2010

我将按照以下步骤逐步完成我迄今所做的工作:

  1. 创建空解决方案
  2. 添加了一个网站WCFService
  3. 从网站上删除了服务和服务
  4. 在解决方案中添加了WCF服务库项目
  5. 为web.config添加了端点
  6. 在app.config中做了同样的事情
  7. 在Web应用程序中添加了对服务库的引用
  8. ctrl + F5 9

我收到以下错误:

'/ WFLedger'应用程序中的服务器错误.无法找到"Service.WFLedger.WF_Ledger"类型,作为ServiceHost指令中的Service属性值提供,或者在配置元素system.serviceModel/serviceHostingEnvironment/serviceActivations中提供.描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.

例外细节:

System.InvalidOperationException:类型为"Services.WFLedger.WF_API_Ledger",作为ServiceHost指令中的Service属性值提供,或者在配置元素system.serviceModel/serviceHostingEnvironment/serviceActivations中提供.

来源错误:

在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.

堆栈跟踪:

[InvalidOperationException:类型'Services.WFLedger.WF_Ledger',作为ServiceHost指令中的Service属性值提供,或者在配置元素system.serviceModel/serviceHostingEnvironment/serviceActivations中提供,无法找到.]
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:由于编译期间发生异常,无法激活服务'/WFLedger/WF_Ledger.svc'.异常消息是:类型"Services.WFAPILedger.WF_API_Ledger",作为ServiceHost指令中的Service属性值提供,或者在配置元素system.serviceModel/serviceHostingEnvironment/serviceActivations中提供,无法找到..]
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

这真让我抓狂!为什么我会收到此错误?如果您需要更多信息,请告诉我,以便我提前向您提供一百万

Six*_*aez 37

查看网站项目中的WF_Ledger.svc文件.它应该只包含一行.将存在包含"Services.WFAPILedger.WF_API_Ledger"的Service属性.WCF正在寻找"Services.WFAPILedger.WF_API_Ledger"类,但没有找到它.名称空间和类名称需要存在于网站项目中,或者在您尝试设置时作为参考.您需要编辑该Service属性以匹配WCF服务库项目中的服务实现类.


Sar*_*gam 5

请检查.svc文件是否已提供且格式如下.

 <% @ServiceHost Language=C# Debug="true" Service="MyService" CodeBehind="~/App_Code/Service.cs" %>
Run Code Online (Sandbox Code Playgroud)

它的所有一行和文件应该只包含其他内容.