如何解析system.serviceModel / serviceHostingEnvironment / serviceActivations找不到。 iis托管的wcf服务出错?

时间:2017-05-05 10:39:10

标签: c# asp.net .net wcf iis

将wcf服务部署到远程iis时出现问题, 首先,我有vs解决方案包含两个项目

  1. WCF库(ExchangeMailCore)
  2. WCF应用程序(ExchangeMailService)
  3. 在我的图书馆项目中,有ExchangeEmailService.csExchangeEmailService.cs个文件。

    enter image description here

    然后我将库包含在ExchangeMailService项目中并创建了新的.svc文件,如下所示

    <%@ServiceHost Language="C#" Debug="true" Service="ExchangeMailCore.ExchangeEmailService" %>
    

    我的web.config文件如下,

    <?xml version="1.0"?>
    <configuration>
    
      <appSettings>
        <!--<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />-->
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
        <add key="ClientSettingsProvider.ServiceUri" value="" />
      </appSettings>
    
    
      <system.web>
    
        <!--<compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>-->
        <compilation debug="true" />
        <membership defaultProvider="ClientAuthenticationMembershipProvider">
          <providers>
            <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
          </providers>
        </membership>
        <roleManager defaultProvider="ClientRoleProvider" enabled="true">
          <providers>
            <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
          </providers>
        </roleManager>
      </system.web>
    
    
    
      <system.serviceModel>
    
        <!--<bindings>
          <basicHttpBinding>
            <binding name="NetTcpBindingEndpointConfig">
              --><!--<security mode="Message" />--><!--
              <security mode="Transport">
                <transport clientCredentialType="Windows">
                </transport>
                --><!--<message clientCredentialType=""/>--><!--
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>-->
    
    
        <!--<services>
          <service name="ExchangeMailCore.ExchangeEmailService">
          </service>
        </services>-->
    
        <services>
          <service name="ExchangeMailCore.ExchangeEmailService">
            <endpoint address="" binding="basicHttpBinding"  contract="ExchangeMailCore.IExchangeEmailService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8734/Design_Time_Addresses/ExchangeMailCore/ExchangeEmailService/" />
              </baseAddresses>
            </host>
          </service>
        </services>
    
    
        <!--<behaviors>
          <serviceBehaviors>
            <behavior>
              --><!-- To avoid disclosing metadata information, set the values below to false before deployment --><!--
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="False"/>
              --><!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --><!--
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>-->
    
    
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, 
              set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="False" />
              <!-- To receive exception details in faults for debugging purposes, 
              set the value below to true.  Set to false before deployment 
              to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
    
    
        <!--<protocolMapping>
            <add binding="basicHttpBinding" scheme="http" />
        </protocolMapping>    
    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />-->
    
      </system.serviceModel>
    
    
    
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
    
      </system.webServer>
    
    </configuration>
    

    这在localhost上完美运行,但是当我部署到远程服务器时,它会出现以下错误,

    enter image description here

    .Net框架是4.5

    有人可以为此提供帮助吗?

1 个答案:

答案 0 :(得分:1)

在度过美好的夜晚之后,我找到了解决方案,解决方案是将所需的库文件(.dll)添加到已部署的文件夹bin文件夹中,我使用EWS进行电子邮件提取,因此我必须将ews库添加到bin文件夹发布的文件夹,谢谢,啤酒花,这将有助于某人。