0
votes
<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.

2
might be a silly question - but is the [yourappname].exe.config file present in the bin folder?Andras Zoltan

2 Answers

0
votes

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.

1
votes

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.