Wcf IIS 寄宿

最近打算开始学习一下wcf,做了一个简单的例子,但是发现使用IIS发布WCF服务总是不能成功。出现以下错误。

 

 1 Server Error in '/wcfservices' Application.
2 --------------------------------------------------------------------------------
3
4 The contract name 'Contracts.ICalculators' could not be found in the list of contracts implemented by the service 'CalculatorService'.
5 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.
6
7 Exception Details: System.InvalidOperationException: The contract name 'Contracts.ICalculators' could not be found in the list of contracts implemented by the service 'CalculatorService'.
8
9 Source Error:
10
11 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.
12
13 Stack Trace:
14
15
16 [InvalidOperationException: The contract name 'Contracts.ICalculators' could not be found in the list of contracts implemented by the service 'CalculatorService'.]
17 System.ServiceModel.Description.ConfigLoader.LookupContract(String contractName, String serviceName) +16521861
18 System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) +421
19 System.ServiceModel.ServiceHostBase.ApplyConfiguration() +156
20 System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +215
21 System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +475
22 System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +43
23 System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +530
24 System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1423
25 System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
26 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172
27
28 [ServiceActivationException: The service '/wcfservices/CalculatorService.svc' cannot be activated due to an exception during compilation. The exception message is: The contract name 'Contracts.ICalculators' could not be found in the list of contracts implemented by the service 'CalculatorService'..]
29 System.Runtime.AsyncResult.End(IAsyncResult result) +900320
30 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +191134
31 System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107
32
33

Google了一把,发现出现这个错误主要可能由以下两种情况导致:

1、This message is often due to an IIS 7 config problem. If you are used to creating a virtual directory pointing to the folder where your service resides, that no longer works. Now, you need to use the "Create Application..." option instead.

2、The problem could also be a in a different namespace in svc file as it is in svc.cs file.In svc file namespace must be in the following format.

Service="Namespace.SvcClassName" 

 

修改以后两个问题之后,服务就可以顺利访问了。

 

转载于:https://www.cnblogs.com/zhstar/archive/2012/02/20/2360671.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值