zoukankan      html  css  js  c++  java
  • 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" 

     

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

    
    
  • 相关阅读:
    方便学习的小idea---技术文章搜索--提高搜索的效率,准确性,有用性
    学习技术的思考
    python学习记录
    大数据的5个大
    业务系统与门户集成
    项目的集成
    记录说的好的话语
    Java过滤器引发的异常:Resource interpreted as Stylesheet but transferred with MIME type text/html
    11g创建表空间和用户(不区分大小写)与导入导出命令
    3. mysql中常用的字符与时间函数
  • 原文地址:https://www.cnblogs.com/zhstar/p/2360671.html
Copyright © 2011-2022 走看看