title: WCF server method - returning DataSet kills output parameters
body: <p>Looking for some collective wisdom.  Here is the situation.  This is using Visual Studio 2008.</p>
  
  <ol>
  <li><p>We have a simple WCF contract exposing the following method:</p>
  
  <pre><code>DataSet ExecuteQuery (out string someStuff);
  </code></pre></li>
  <li><p>This method is implemented as:</p>
  
  <pre><code>public DataSet ExecuteQuery (out string someStuff)
  {
      someStuff = "abc";
      return new DataSet(); // simplified
  }
  </code></pre></li>
  <li><p>Client side proxy is generated by svcutil, and appears to be correct.</p></li>
  </ol>
  
  <p><strong>Problem:</strong></p>
  
  <p><code>someStuff</code> is always null on the client side.</p>
  
  <p><strong>Observations:</strong></p>
  
  <ol>
  <li>Same problem appears on our build machine.</li>
  <li><p>Returning a string instead of DataSet makes client proxy receive proper value of out parameter:</p>
  
  <pre><code>public string ExecuteQuery(out string someStuff) ...
  </code></pre></li>
  <li><p>Removing the client proxy completely and regenerating it doesn't help.</p></li>
  <li>Client definitely receives both DataSet and the "out" string, as seen in its trace log:</li>
  </ol>
  
  <p><code>
  &lt;ExecuteQueryResponse xmlns="http://tempuri.org/"&gt;
     &lt;ExecuteQueryResult&gt;
         &lt;xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;
  &lt;xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"&gt;
  &lt;xs:complexType&gt;
  &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;&lt;/xs:choice&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  &lt;diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"&gt;&lt;/diffgr:diffgram&gt;
  &lt;/ExecuteQueryResult&gt;
  &lt;someStuff&gt;abc&lt;/someStuff&gt;
  &lt;/ExecuteQueryResponse&gt;</code></p>
  
  <ol start="5">
  <li><p>Here is how the client proxy generates the code:</p>
  
  <pre><code>[System.ServiceModel.OperationContractAttribute 
  (Action="http://tempuri.org/IQueryContract/ExecuteQuery", 
  ReplyAction="http://tempuri.org/IQueryContract/ExecuteQueryResponse")]
  [System.ServiceModel.XmlSerializerFormatAttribute()]
  System.Data.DataSet ExecuteQuery(out string someStuff);
  </code></pre></li>
  <li>We use netTcpBinding</li>
  </ol>
  
  <p>Do we need to do anything special in order to return DataSet and out parameters?  Anyone has come across anything similar?</p>
  
  <p>Thanks!!!!</p>