title: Why can't EventData.GetBytes() be called before sending?
body: <p>I'm working with Azure Event Hubs and initially when sending data to try and calculate batch size I had code similar to the below that would call <a href="http://msdn.microsoft.com/en-us/library/azure/microsoft.servicebus.messaging.eventdata.aspx" rel="nofollow">EventData</a>.<a href="http://msdn.microsoft.com/en-us/library/azure/microsoft.servicebus.messaging.eventdata.getbytes.aspx" rel="nofollow">GetBytes</a></p>
  
  <pre><code>EventHubClient client;//initialized before the relevant code
  
  EventData curr = new EventData(data);
  //Setting a partition key, and other operations.
  long itemLength = curr.GetBytes().LongLength;
  client.SendAsync(curr);
  </code></pre>
  
  <p>Unfortunately I would receive an exception in the SDK code.</p>
  
  <blockquote>
    <p>The message body cannot be read multiple times. To reuse it store the value after reading.</p>
  </blockquote>
  
  <p>While removing the ultimately unnecessary call to GetBytes meant that I could send messages, the rationale for this exception to occur is rather puzzling. Calling GetBytes() twice in a row is an easy way to reproduce the same exception, but a single call will mean that the EventData cannot be sent successfully.</p>
  
  <p>It seems likely that underneath a <a href="http://msdn.microsoft.com/en-us/library/System.ServiceModel.Channels.Message_methods%28v=vs.110%29.aspx" rel="nofollow">Message</a> is used and this is set to throw an exception if called more than once as <a href="http://msdn.microsoft.com/en-us/library/ms195456.aspx" rel="nofollow">Message.GetBody</a> documents; however, there is no documentation to this effect in EventData's methods <a href="http://msdn.microsoft.com/en-us/library/azure/microsoft.servicebus.messaging.eventdata.getbodystream.aspx" rel="nofollow">GetBodyStream</a>, <a href="http://msdn.microsoft.com/en-us/library/azure/dn727403.aspx" rel="nofollow">GetBody w/serializer</a>, <a href="http://msdn.microsoft.com/en-us/library/azure/dn751690.aspx" rel="nofollow">GetBody</a>, or <a href="http://msdn.microsoft.com/en-us/library/azure/microsoft.servicebus.messaging.eventdata.getbytes.aspx" rel="nofollow">GetBytes</a>.</p>
  
  <p>I imagine this should either be documented, or corrected since currently it is an unpleasant surprise in a separate thread.</p>