tags:

views:

71

answers:

2

I created a proxy Library Class in the Service Solution referencing the Contract Assembly as well and copied the libraries (Contract,Proxy) to another solution folder. Then referenced the Proxy,Contract and System.ServiceModel libraries in another class library where i need to use the one method contained, as well as adding an App.Config inside the library.

The Service is hosted in a windows forms application. The client is a class library called from a windows forms application.I haven't created an App.Config inside the windows form project. In fact the Windows Form project loads a control in a library and the control loads the library where i need to use the service method. So i thought i should only reference the (Contract and proxy) in the latest assembly since i wont use it anywhere else.

But i keep getting this error:

Could not find default endpoint element that references contract 'Sign.Contracts.ISignDocument' 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.

App.Config in libray calling the proxy:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <client>
        <endpoint
          address="http://localhost:8731/SignHere"
          binding="basicHttpBinding"
          contract="Sign.Contracts.ISignDocument" />
      </client>
    </services>
  </system.serviceModel>
</configuration>

App.Config in service Host:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="Sign.Service.SignDocumentService">
        <endpoint 
          address="http://localhost:8731/SignHere" 
          binding="basicHttpBinding" 
          contract="Sign.Contracts.ISignDocument" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

the Proxy class:

namespace Sign.Proxies
{
    public class Proxy : ClientBase<ISignDocument>, ISignDocument
    {
        public string SignDocument(string document)
        {
            return Channel.SignDocument(document);
        }
    }
}

the Contract class:

namespace Sign.Contracts
{
    [ServiceContract]
    public interface ISignDocument
    {
        [OperationContract]
        string SignDocument(string document);
    }
}

Any ideas?

+1  A: 

Any program has only a single configuration file. In your case, that's the app.config of the Winforms program, which gets copied to programName.exe.config when the program is built.

Any WCF configuration has to be in that file. The fact that your library has an app.config doesn't matter. You need to copy the relevant configuration entries from the library's app.config, and merge them with the app.config of the Winforms application.

John Saunders
Added a App.Config file in the winform project and i get same error.
AlwaysBeCoding
That's not the problem. You need to copy the WCF configuration from your library's app.config into the app.config in the Winforms application.
John Saunders
yes, sorry thats what i meant, i created an App.Config file in the winforms application and copied the contents.
AlwaysBeCoding
+1  A: 

doooh...there is no parent element for the client endpoint information in the client app.config.

AlwaysBeCoding