WCF, the Service attribute value in the ServiceHost directive could not be found.

本文介绍了一种在WCF服务中遇到的ServiceActivationException异常情况,并详细解释了导致此问题的原因在于服务类定义与配置文件中指定的服务类型不匹配。通过调整.svc文件和服务实现的一致性,成功解决了该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Server Error in '/InsusSiteCS' Application.


The type 'Catalog', 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 'Catalog', 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 'Catalog', 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) +59638
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1434
   System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +52
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +598

[ServiceActivationException: The service '/InsusSiteCS/WCF/Catalog.svc' cannot be activated due to an exception during compilation.  The exception message is: The type 'Catalog', 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) +495736
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +229
   System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context) +24
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
                  

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18010

 

Insus.NET有写一个WCF Service ,在测试时,出现如上错误。

经过仔细检查与debug,才发现原来是因为在建立Service时,自己添加上命名空间,而在.svc即没有去添加。

 

解决问题:

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值