0

I am trying to add a reference to a WCF service from my C# Desktop app.

I can add the service reference OK but as soon as I try to open the form within this desktop app I get this error:

NB. I have a UserControl that instantiates a reference to my WCF service and the control in in my GUI Form Class.

Could not find default endpoint element that references contract '' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

This is in my app.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IMotionUpdater" messageEncoding="Mtom" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://a url/MotionUpdater.svc/MotionUpdater.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMotionUpdater"
                contract="wsCloudFeeder.IMotionUpdater" name="BasicHttpBinding_IMotionUpdater" />
        </client>
    </system.serviceModel>
</configuration>

And this is in my web.config file:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBindingEndPoint" maxReceivedMessageSize="10485760"   messageEncoding="Mtom" closeTimeout="00:00:10" openTimeout="00:00:10" >
          <readerQuotas maxArrayLength="32768"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="MotionUpdater" behaviorConfiguration="ThrottledBehavior">
        <endpoint address="MotionUpdater.svc" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingEndPoint" contract="IMotionUpdater"></endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ThrottledBehavior">
          <serviceTimeouts transactionTimeout="1"/>
          <serviceThrottling maxConcurrentCalls="64" maxConcurrentInstances="1" maxConcurrentSessions="50"
             ></serviceThrottling>/>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

If I invoke this reference from a browser window it displays all OK.

It is only where I have a variable in my form class I get the error:

UserControl.Class:

 private static wsCloudFeeder.MotionUpdaterClient wsFeeder = new wsCloudFeeder.MotionUpdaterClient();

Server Class:

[ServiceContract]
public interface IMotionUpdater
{
    [OperationContract]
    void UploadMotion(byte[] jpegStream, string alias, Int16 camIndex);
}

The extra weird thing is that when I run my application it all works no problem.

Also, I have tried just doing this in my control Class but still cannot open up my GUI form..

 private static wsCloudFeeder.MotionUpdaterClient wsFeeder = null;

Thanks...

New Error:

enter image description here

Andrew Simpson
  • 6,883
  • 11
  • 79
  • 179
  • 2
    Do you have double `MotionUpdater.svc` in the client's endpoint address? Why? – Szymon Dec 12 '13 at 11:42
  • I would recommend deleting the service reference and add it again, sounds like you service ref is bad. – Jocke Dec 12 '13 at 11:44
  • @Jocke Hi, thanks for responding. That was the 1st thing I did – Andrew Simpson Dec 12 '13 at 11:52
  • How is your solution structured? Check out this post: http://stackoverflow.com/questions/352654/could-not-find-default-endpoint-element – Jocke Dec 12 '13 at 11:55
  • @Szymon wish I spotted that. It was automatically generated when the reference was made. I have removed the double ebtry but the error/situation still persists – Andrew Simpson Dec 12 '13 at 11:55
  • Is the contract name correct in the clients config?wsCloudFeeder.IMotionUpdater or IMotionUpdater? – Jocke Dec 12 '13 at 12:00
  • @Jocke HI, thanks for trying to help me.I did come across that link myself but this did not reflect my architecture. I have removed the wsCloudFeeder. This did not work for me either. What a pain! – Andrew Simpson Dec 12 '13 at 12:05
  • 1
    I would try to create a new console app and add the service reference to that solution and try call the method from that on. If it works (and the configs are the same) you can rule out the proxy... is the client and service using the same version of system.componentmodel? – Jocke Dec 12 '13 at 12:09
  • 1). was just in the process of doing just that (re: console) but am doing 2). as the server version of VS2010 does not match the client 1 in terms of service pack. I am not on the ball today, but you are. let see what an update will do. thanks :) – Andrew Simpson Dec 12 '13 at 12:16
  • Have you checked that it does indeed load the correct .config file? – scheien Dec 12 '13 at 12:23
  • @scheien Hi, my ignorance is going to show here. I have 1 web config on my web site and I have an app.config on my client app. I know that there are machine host configs but even though I am getting an error the message does mention my service name. So it must be referencing the correct or..? – Andrew Simpson Dec 12 '13 at 12:29
  • I can't see that it's referencing your service in the error posted. But it may fetch the name from the classes generated from the wsdl. The client solution, does it consist of one or more projects? – scheien Dec 12 '13 at 12:39
  • @scheien Hi, I have already added the reference to my project. There is 1 client project only and 1 web project only. A bit confused as to what you are asking? Thanks though :) – Andrew Simpson Dec 12 '13 at 12:41
  • @AndrewSimpson - Just had a hunch, and I was wrong :) – scheien Dec 12 '13 at 12:45
  • That's OK was not being critical. It was fair question. Thanks – Andrew Simpson Dec 12 '13 at 12:45
  • Is the name of your config file MyApp.exe.config? – scheien Dec 12 '13 at 12:55
  • Yes it is. i created new console app. Same error. i updated the vs2010 on my server with latest server pack. Same error.. – Andrew Simpson Dec 12 '13 at 13:17
  • does anyone think it will be better to make the reference in code and not use the config file? If so does anyone have a simple easy to understand link that will allow me to do that pls? – Andrew Simpson Dec 12 '13 at 13:53
  • I just deleted the old wcf on the server and removed all references from it on the client. I then created a new service and gave it a different name. I then made a reference to it in my code with a usercontrol. I then went to my gui form and tried to drag and drop this control onto the form. I got this error (added to question): – Andrew Simpson Dec 12 '13 at 14:04

0 Answers0