Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Microsoft says that you always have to close the connection at the end (see the <a href="http://msdn.microsoft.com/en-us/library/ms751475%28v=vs.90%29.aspx" rel="nofollow noreferrer">example</a> at MSDN). I've found the following pattern in this <a href="http://www.codeproject.com/Articles/74129/The-Proper-Use-and-Disposal-of-WCF-Channels-or-Com" rel="nofollow noreferrer">article about WCF disposal handling</a>:</p> <pre><code>WCFServiceClient c = new WCFServiceClient(); try { c.HelloWorld(); } catch { // acknowledge the Faulted state and transition to Closed c.Abort(); // handle or throw throw; } finally { c.Close(); } </code></pre> <p>The article says you should <strong>avoid</strong> <code>using</code> since it does not properly close and dispose the WCF service client object, you should do it with a <code>try ... catch ... finally</code> block instead as shown above - this way you're dealing with exceptions (which will abort and then re-throw or handle the exception) and also you take care of finally closing the connection. This is also clearly stated in <a href="http://msdn.microsoft.com/en-us/library/aa355056%28v=vs.90%29.aspx" rel="nofollow noreferrer">Microsoft's WCF troubleshooting hints.</a></p> <p><strong>Note:</strong> The <code>c.Close()</code> in the <code>finally</code> does not do any harm in case of an exception (faulted state), because we call <code>c.Abort()</code> before the exception is re-thrown so the <code>c.Close()</code> does actually nothing in this case. However, if no exception occurs, then <code>c.Close()</code> is actually executed normally and the connection closes as expected.</p> <p>If your <strong>WCF service</strong> behaves in a strange way, there are many (other) things which could cause this - <a href="https://stackoverflow.com/a/12800645/1016343">here</a> you can find some debugging hints.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload