0

I have a Winforms application that talks to a WCF service. When run, it works.

However, when you load a form that has a dependency on one of the datatypes in the service, it fails. In fact, it then crashes VS2017 and VS2015, making it tougher.

The error, if I can catch it before VS restarts, is that the client configuration for the endpoint is wrong. Yet it does work when you press F5 and run the app! I'm hoping that if I post the servicemodel sections of the service and the app someone will be able to spot the misconfiguration:

In the service library's app.config I have:

<system.serviceModel>
<services>
  <service name="SapphireServiceLib.SapphireService"
           behaviorConfiguration="SoapToRESTfullDemo.Service1Behavior">

    <endpoint address=""
              binding="wsHttpBinding"
              contract="SapphireServiceLib.ISapphireService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8888/sapphireservice" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="SoapToRESTfullDemo.Service1Behavior">
      <!-- To avoid disclosing metadata information, 
      set the value below to false and remove the metadata endpoint above 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="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>

...and in the EXE's app.config I have the following:

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_ISapphireService" />
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:8888/sapphireservice" 
            binding="wsHttpBinding"
            bindingConfiguration="WSHttpBinding_ISapphireService" 
            contract="SapphireServiceReference.ISapphireService"
            name="WSHttpBinding_ISapphireService">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

Can anyone spot anything obvious? Clearly the VS designer needs to be able to connect to the endpoint at design time to access the classes that it needs for the form, but that endpoint connection is only working at runtime, not at design time.

Peter Bons
  • 26,826
  • 4
  • 50
  • 74
Dave
  • 1,521
  • 17
  • 31
  • Any exception info? – Jim W Nov 08 '17 at 19:19
  • How is your form constructed and initialized? I would make sure that there is no communication setup when in design mode. – Peter Bons Nov 08 '17 at 19:30
  • I was assuming he wanted communication in design mode. – Jim W Nov 08 '17 at 19:43
  • I'm going to try to not have any communication in design mode as a temporary hack, but ideally it would "just work" without any coding around it... so if I can make it work in design mode, please let me know how! – Dave Nov 09 '17 at 00:09

0 Answers0