c# - 如何解决找不到 system.serviceModel/serviceHostingEnvironment/serviceActivations 的问题。 iis 托管的 wcf 服务出错?

标签 c# asp.net .net wcf iis

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

  1. WCF 库 (ExchangeMailCore)
  2. WCF 应用程序(ExchangeMailService)

在我的库项目中有 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>

这在本地主机上完美运行,但是当我部署到远程服务器时,它给出以下错误,

enter image description here

.Net框架是4.5

有人可以帮忙吗?

最佳答案

度过美丽的夜晚后,我找到了解决方案,解决方案是将所需的库文件(.dll)添加到部署的文件夹 bin 文件夹中,我使用 EWS 进行电子邮件提取,所以我必须将 ews 库添加到 bin 文件夹中发布的文件夹,谢谢,希望这会对某人有所帮助。

关于c# - 如何解决找不到 system.serviceModel/serviceHostingEnvironment/serviceActivations 的问题。 iis 托管的 wcf 服务出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43802845/

相关文章:

c# - 在 IIS 上更改 targetFramework

c# - 将 JSON 写入流而不在内存中缓冲字符串

c# - WPF 图像 - 尝试使用 TreeView ,但无法使背景清晰

asp.net - 使用 Microsoft.Web.Administration 所需的权限

asp.net - HttpRuntime 缓存的生命周期是多少(任何简单的替代方案?)

c# - 我可以用来定义同名方法的最佳设计是什么?

.net - 当 View 不与模型交互时,它是 MVC 吗?

c# - 使用动态/DLR 的 DynamicProxy

c# - 使用 LINQ 进行“智能”分组

c# - ASP.NET 对话框建议