Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF fails when returning data
    primarykey
    data
    text
    <p>My first forays into WCF. The class <code>HardDrive</code> goes and collects a bunch of WMI information about locally connected drives. For some reason, when it attempts to return the <code>List&lt;HardDrive&gt;</code> to the client, I get </p> <blockquote> <p><em>The underlying connection was closed: The connection was closed unexpectedly.</em></p> </blockquote> <p>Which is one of those totally unhelpful error messages. </p> <p>I've done step-by-step debugging, so I <em>know</em> it's crashing when it tries to return the list back to the client. I just don't know <em>why</em>. </p> <p>My best guess is something to do with the size of the returned list, but...it's not going to be that big, I wouldn't think? </p> <p>I've tested this returning a basic string and it works fine. </p> <pre><code>namespace FCopyDataService { public class FCopyDataService : IFCopyDataService { public List&lt;HardDrive&gt; GetAllHardDrives() { return HardDrive.GetHardDrives(); //this returns quite happily } public List&lt;Partition&gt; GetAllPartitions(HardDrive currentDrive) { return HardDrive.GetPartitions(currentDrive); } } } </code></pre> <p>I call it from the client using: </p> <pre><code>private void button1_Click(object sender, EventArgs e) { FCopyDataServiceClient drives = new FCopyDataServiceClient(); drives.Open(); //checks it's open List&lt;HardDrive&gt; receivedDrives = drives.GetAllHardDrives(); //crashes here } </code></pre> <p>My service config:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;httpRuntime maxRequestLength="102400" /&gt; &lt;/system.web&gt; &lt;system.serviceModel&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior&gt; &lt;serviceMetadata httpGetEnabled="true"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt; &lt;/system.serviceModel&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"/&gt; &lt;/system.webServer&gt; &lt;/configuration&gt; </code></pre> <p>And my client config, with some odd bits because I've been trying to work this out. </p> <pre><code>&lt;system.serviceModel&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;binding name="BasicHttpBinding_IFCopyDataService" 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"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&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://localhost:19140/FCopyDataService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFCopyDataService" contract="FCopyDataService.IFCopyDataService" name="BasicHttpBinding_IFCopyDataService" /&gt; &lt;/client&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior&gt; &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior &gt; &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; </code></pre>
    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.
 

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