我正在研究WCF,它在localhost上运行良好。将它放在生产服务器上后,它会抛出异常
请求的服务“http://global-kazway.kz/Service1.svc”可以 不被激活。有关更多信息,请参阅服务器的诊断跟踪日志 信息
我是服务新手,并且已经尝试解决这个问题将近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="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"" 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="data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\AppData\DB.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" 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>
答案 0 :(得分:67)
对WCF应用程序进行故障排除的第一步是打开浏览器并输入服务URI。因此,基于客户端:您将导航到http://global-kazway.kz/Service1.svc
现在看看你得到了什么样的结果。例外?服务屏幕?通常,您可以从此屏幕获取最佳信息!有时它指出你的问题是什么,比如错过了一个行为。
将您的web.config与已部署的web.config条目进行比较。你也可以找到一些东西。最后,您可能只需要管理文件夹的安全性。但浏览器显示可以非常清楚地为您解释所有内容。
答案 1 :(得分:7)
我正在研究一个项目,我遇到了同样的问题。 当我检查事件查看器以跟踪错误时,我发现了问题所在。
事件查看器消息:
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" />
此元素应放在<system.serviceModel>
答案 2 :(得分:4)
我正在为WCF工作,它在localhost上运行良好。我把它放到生产服务器后,它给我一个例外“请求的服务,'http://global-kazway.kz/Service1.svc'无法激活。有关详细信息,请参阅服务器的诊断跟踪日志“
This MSDN article describes how to configure tracing on the server。完成后,您可以查看服务器的诊断跟踪日志,并可能发现问题。
答案 3 :(得分:2)
要获得更详细的错误说明,请将此代码插入服务的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>
确保您的基地址不是localhost。 TC
答案 4 :(得分:2)
我可以使用Visual Studio 2013执行以下步骤来解决此问题:
答案 5 :(得分:2)
首先获取服务URL地址(例如http://youservice:808/Area.Service/Service.svc)并将其放入浏览器URL字段以检查服务是否正在运行。
就我而言,它没有运行。
远程服务器运行的进程使用了很多或CPU和RAM(sql进程)
这阻止了这项服务。
通过关闭/停止远程服务器上任务管理器中的某些进程恢复服务。
答案 6 :(得分:0)