先写了一个WCF服务 ,发布到了IIS上,然后又创建一个窗体程序,添加引用服务的时候成功地把服务引了进来,可是在执行窗体程序的时候出错,提示“在 ServiceModel 客户端配置部分中,找不到引用协定“ServiceReference1.ISendJsonIntoDatabase”的默认终结点元素。这可能是因为未找到应用程序的配置文件,或者是因为客户端元素中找不到与此协定匹配的终结点元素。”
这是为什么呢?我看网上说可能和wcf和窗体程序的配置文件有关,下面列出,麻烦大家帮忙找一下原因
WCF配置文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime requestPathInvalidCharacters="" targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="httpBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service name="TestWCFPub.SendJsonIntoDatabase">
<endpoint bindingConfiguration="webBinding" address="" behaviorConfiguration="httpBehavior" binding="webHttpBinding" contract="TestWCFPub.ISendJsonIntoDatabase"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webBinding" maxReceivedMessageSize="2147483647" crossDomainScriptAccessEnabled="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>-->
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!-- contract="ws.SendJsonIntoDatabaseClient"
若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
multipleSiteBindingsEnabled="true"
在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
窗体程序配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>