title: C#: WebService won't work in external .NET-DLL
body: <p><strong>EDIT: I cleaned a little up to make more clear, what's my problem. Sorry, it's less than it may look like. The whole xml is blowing up this post pretty much</strong></p>
  
  <p>I have a web service running on a remote server - a Linux device where some hardware is attached. This hardware, usually controlled by the linux server may also be connected over a web service by using wsdl. I got this project from a former employee and totally hung right now, because the web service won't work as I expect it.</p>
  
  <p>As far as I understood the concept of webservices they deliver an interface which can be imported to a project to access the webservice as if it was a local library. </p>
  
  <p>Hence I have added a new library to my solution, added a new service reference and downloaded the whole interface into my project (Project explorer->References->Add service reference). Now I have a DLL containing all the methods of webservice (service.dll) - so far, so good.</p>
  
  <p>What I dont understand: This wizzard now created an app.config which - for my understanding is obsolete. The app.config contains:</p>
  
  <pre><code>  &lt;configuration&gt;
        &lt;system.serviceModel&gt;
            &lt;bindings&gt;
                &lt;basicHttpBinding&gt;
                    &lt;binding name="ImageServerServiceSoapBinding" /&gt;
                &lt;/basicHttpBinding&gt;
            &lt;/bindings&gt;
            &lt;client&gt;
                &lt;endpoint address="http://10.80.30.200:50000/xxxDataServer"
                    binding="basicHttpBinding" bindingConfiguration="ImageServerServiceSoapBinding"
                    contract="ServiceReference1.ImageServer" name="ImageServerPort" /&gt;
            &lt;/client&gt;
        &lt;/system.serviceModel&gt;
    &lt;/configuration&gt;
  </code></pre>
  
  <p>Now I use this Service DLL in another project (driver.dll) where I implement access and unsage of the service encapsuled in a driver.</p>
  
  <pre><code>using MyService.ServiceReference1
  // ...
  public class MyClient
  {
  public void Connect() {
      this._Client = new ImageServerClient(
          _Settings.EndPointConfigurationName,
          @"http://" + _Settings.Physicals.IPAdress + ":" + 
          _Settings.Physicals.Port + _Settings.Physicals.SubDir);
  }
  </code></pre>
  
  <p>The address built in the upper code points at:
      <a href="http://10.80.30.200:50000/xxxDataServer" rel="nofollow">http://10.80.30.200:50000/xxxDataServer</a>
  which is the same directory as the one used in the wsdl import wizzard.</p>
  
  <p>The ImageServerClient is a part of the imported interface. It's definition is:</p>
  
  <pre><code>[System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
  public partial class ImageServerClient : System.ServiceModel.ClientBase&lt;MySerivce.ServiceReference1.ImageServer&gt;, MySerivce.ServiceReference1.ImageServer {
  
      public ImageServerClient(string endpointConfigurationName, string remoteAddress) : 
              base(endpointConfigurationName, remoteAddress) {
      }
  </code></pre>
  
  <p>For debugging purposes I have another Project (test.exe) in my solution referencing to the driver.dll.</p>
  
  <p>In this test.exe I call the function </p>
  
  <pre><code>Client = new MyClient(MySettings);
  Client.Connect();
  </code></pre>
  
  <p>So far so good. Calling the connect function in my driver.dll will call the service.dll to connect to the remote client. </p>
  
  <p>This will work as long as the calling test.exe is holding the following information in the app.config:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="ImageServerServiceSoapBinding" messageEncoding="Mtom" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"&gt;
            &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/&gt;
            &lt;security mode="None"&gt;
              &lt;transport clientCredentialType="None" proxyCredentialType="None" realm=""/&gt;
              &lt;message clientCredentialType="UserName" algorithmSuite="Default"/&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
        &lt;endpoint address="http://10.80.30.200:50000/xxxDataServer" binding="basicHttpBinding" bindingConfiguration="ImageServerServiceSoapBinding" contract="ServiceReference1.ImageServer" name="ImageServerPort"/&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>The the then calling LabView is not compatible with the app.config scheme and therefore the driver.dll has to work autonomously without any additional config outside the driver.dll or the service.dll.</p>
  
  <p>Removing the app.config data will end up in an error in the line:</p>
  
  <pre><code>this._Client = new ImageServerClient(Settings.EndPointConfigurationName,
                                       @"http://" + _Settings.Physicals.IPAdress + ":" + 
                                       _Settings.Physicals.Port + _Settings.Physicals.SubDir);
  </code></pre>
  
  <p><em>InvalidOperationException in System.ServiceModel.dll
  There was no endpoint element found with the Name "..." and the contract "..." in the ServiceModel-ClientConfiguration. This may have the folowing reasons: There was no configuration file found for this application or there was no EndPoint-Element found within the client element that matches the name.</em> (Translated from german).</p>
  
  <p>So what is wrong in my thoughts that this is not working? Why is it not enough, that all the basicHttpBinding stuff is already in the app.config from the service.dll (created by the wizzard)? Thank you :)</p>