0
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="ep1" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:57582/Service1.svc" binding="basicHttpBinding"
                bindingConfiguration="ep1" contract="ServiceReference1.IService1"
                name="ep1" />
        </client>
    </system.serviceModel>
</configuration>

this is my configuration for client-endpoint in autogenerated app.config file but still i get following error: Could not find endpoint element with name 'ep1' and contract 'ServiceReference1.IService1' 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 name could be found in the client element.

i am consuming the service using ::

Service1Client wcf = new Service1Client("ep1")

enter image description here


Its working now.i just defined the client endpoint in web.config of whole solutions from the autogenerated app.config file.its working now.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
lovin
  • 563
  • 2
  • 14
  • 27

2 Answers2

1

If this is a windows application project you need to add an 'application configuration file' (leave the name as app.config), if you already have one in the root of your project, no problem.

If it's a web project - then you need to be targetting it's web.config.

Next, copy the above configuration to that and then rebuild and run. It should then work.

Andras Zoltan
  • 41,961
  • 13
  • 104
  • 160
0

Almost certainly what is hapenning is that your running code is reading from a config file which does not have this endpoint defined. Are you certain you are looking at the config file from the build output location?

My guess is you need to set copy local = true on the config file.

tom redfern
  • 30,562
  • 14
  • 91
  • 126
  • this endpoint is defined.i have pasted the config code above. – lovin May 30 '12 at 12:44
  • Can you also post the file path the config file? – tom redfern May 30 '12 at 13:34
  • its under a class file where i added the service reference. – lovin May 30 '12 at 13:47
  • Can you see the file in the bin folder? – tom redfern May 30 '12 at 13:50
  • there is no bin folder created.it is the same app.config file autogenerated while adding the service reference. – lovin May 30 '12 at 13:52
  • When you run your app your code is being built to a directory from where it will then run. The location of this directory depends on lots of things but generally it will be in a folder called bin\debug off your project root. I think the problem you are having is that the config you are looking at on your screen is not the same config which is being read by the code running from the build output directory, and that the config file in the output dir either does not exist or if it does it does not define the endpoint required by the code. Can you find where you code is running from? – tom redfern May 30 '12 at 14:09