Can';t激活WCF服务

Can';t激活WCF服务,wcf,Wcf,我正在使用WCF,它在本地主机上运行良好。在我把它放到生产服务器上之后,它出现了一个异常 请求的服务“”无法启动 不能被激活。有关更多信息,请参阅服务器的诊断跟踪日志 信息 我是服务行业的新手,已经尝试解决这个问题将近3个小时了 这是客户端的App.config <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections></configSections> &

我正在使用WCF,它在本地主机上运行良好。在我把它放到生产服务器上之后,它出现了一个异常

请求的服务“”无法启动 不能被激活。有关更多信息,请参阅服务器的诊断跟踪日志 信息

我是服务行业的新手,已经尝试解决这个问题将近3个小时了

这是客户端的
App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections></configSections>
  <connectionStrings>
    <add name="TestProject.Properties.Settings.DBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\1\Documents\visual studio 2010\Projects\TestProject\TestProject\AppData\DB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /><add name="DBEntities" connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=C:\Users\1\Documents\visual studio 2010\Projects\TestProject\TestProject\AppData\DB.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /><add name="DBEntities1" connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\AppData\DB.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://global-kazway.kz/Service1.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IService1" contract="kazwayServiceReference.IService1"
        name="BasicHttpBinding_IService1" />
    </client>
  </system.serviceModel>
</configuration>

对WCF应用程序进行故障排除的第一步是打开浏览器并键入服务URI。因此,基于客户端:您可以导航到

现在看看你得到了什么样的结果。例外?服务屏幕?通常你可以从这个屏幕上获得最好的信息!有时它会指出您的问题所在,例如缺少行为

将您的web.config与部署的web.config条目进行比较。你也可以在那里找到一些东西。最后,您可能只需要管理文件夹的安全性。但是浏览器的显示可以非常清楚地为你解释一切

我正在使用WCF,它在本地主机上运行得很好。在我把它放到生产服务器上之后,它给我带来了一个异常“请求的服务”http://global-kazway.kz/Service1.svc'无法激活。有关详细信息,请参阅服务器的诊断跟踪日志。


。完成此操作后,您可以查看服务器的诊断跟踪日志,很可能会发现问题。

若要更详细地描述错误,请在服务的web.config文件中插入以下代码:-

  <serviceBehaviors>
    <behavior name="MyServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>

然后在您的服务中使用此服务行为,如下所示:-

<service name="MyService" behaviorConfiguration="MyServiceBehavior" >
        <endpoint address="" binding="basicHttpBinding"  xxxx="" xxxxx="" xxxxx="" xxxx="" xxxx="" />
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
        <host>
          <baseAddresses>
            <add baseAddress="http://ServerAddress:AnyPortIfspecified/VirtualDirname"/>
          </baseAddresses>
        </host>
      </service>

这将为您提供错误的详细描述

您可以尝试的第二件事是检查以下内容:-

<host>
        <baseAddresses>
          <add baseAddress="http://ServerAddress:AnyPortIf specified/VirtualDir name"/>
        </baseAddresses>
      </host>

确保您的基址不是本地主机。
TC

我在做一个项目,我面临着同样的问题。 当我检查事件查看器以跟踪错误时,我找到了问题所在

事件查看器消息:

Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/7540993
 Exception: System.ServiceModel.ServiceActivationException: The service '/CODWebService/Service1.svc' cannot be activated due to an exception during compilation.  The exception message is: Memory gates checking failed because the free memory (164065280 bytes) is less than 5% of total memory.  As a result, the service will not be available for incoming requests.  To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.. ---> System.InsufficientMemoryException: Memory gates checking failed because the free memory (164065280 bytes) is less than 5% of total memory.  As a result, the service will not be available for incoming requests.  To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.
然后我将下面的代码添加到我的服务的web.config文件中

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="1" />


此元素应放在

中。我使用Visual Studio 2013通过以下步骤解决了此问题:

  • 转到包含*.svc文件的项目文件夹
  • 右键单击*.svc文件-->在浏览器中查看
  • 验证您是否能够浏览该服务
  • 转到包含app.config文件或要使用该服务的项目文件夹
  • 右键单击项目-->添加-->服务参考
  • 单击“服务”下的“发现”-->选择服务-->为服务引用提供所需名称-->单击“确定”
  • 它将在“服务引用”文件夹下创建“ServiceReference1”&自动创建/更新app.config文件

  • 首先,获取服务url地址(例如),并将其放入浏览器url字段,以检查服务是否正在运行

    就我而言,它没有运行

    远程服务器运行的进程使用了大量CPU和RAM(sql进程)

    这阻碍了服务


    通过关闭/停止远程服务器上Task Manager中的某些进程,恢复了服务。

    除了接受的答案之外,我还访问了
    service.svc
    在URL中映射的确切URL

    从这里您可以看到详细的问题,在我的案例中,这是一个错误:


    在这个问题上,我在web.config文件上有正确的配置,但我注意到它正在查找程序集,从那里,我发现我没有引用服务契约项目,包括服务实现和数据访问层程序集

    请同时提供服务的配置。我想在我的应用程序中添加一个
    行为
    ,以弄清这个问题的根源,但您的答案似乎不完整。“this:-”之后没有任何内容。尽管如此,我还是对你的答案投了赞成票,因为它为我指明了正确的方向。