qq_25006515 2015-03-20 08:30 采纳率: 57.4%
浏览 2612

C#窗体程序调用WCF出错

先写了一个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>

  • 写回答

2条回答 默认 最新

  • Metz 2015-03-20 10:17
    关注

    关注一下~~~~~~~~

    评论

报告相同问题?

悬赏问题

  • ¥20 蓝牙耳机怎么查看日志
  • ¥15 R语言 拟时序分析降维图如何减少分支
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统