我做了一个连接SQL DB和获取数据到Windows Store应用程序的WCF…昨天还好。我可以从数据库获取数据到客户端应用程序。今天我再次打开解决方案,令我惊讶的是,它只是停止工作,就像那样…
我一直在论坛上搜索一些想法,但没有得到任何积极的结果。
我没有改变任何一行代码,我真的不知道发生了什么。我试着做一个新的解决方案,一个有这个功能的新项目,但什么都没有,就是行不通。我试图改变wcf app.config,但没有任何成功。有人能给我一些建议来解决这个问题吗?
这是我的WCF应用程序配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="WcfBD.Properties.Settings.ProjetoFinalConnectionString"
connectionString="Data Source=Asus;Initial Catalog=ProjetoFinal;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfBD.BaseDadosWCF">
<endpoint address="" binding="basicHttpBinding" contract="WcfBD.IBaseDadosWCF">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfBD/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我分享我的WCF服务配置供您参考。你检查你的服务合同
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false"/>
<services>
<service behaviorConfiguration="ServiceBehaviour" name="DataService.DataService">
<endpoint address="web" behaviorConfiguration="jsonBehavior" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" contract="DataService.IDataService"/>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="DataService.IDataService" />
<endpoint address="soap" binding="basicHttpBinding" contract="DataService.IDataService"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<webHttp helpEnabled="true" faultExceptionEnabled="True" defaultBodyStyle="Bare" defaultOutgoingResponseFormat="Xml"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- 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" httpHelpPageEnabled="True"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" allowCookies="true">
<security mode="None"></security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBinding" allowCookies="true">
<security mode="None"></security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
也许你的web服务器不能正常工作?我想如果你什么都没碰,那可能是网络服务器出了问题。首先,检查一下您的IIS,并尝试重新启动它。