Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Looks like primarily <code>InvalidOperationException</code>.</p> <p>If you go through the documentation for each of the overloads, it will give you more details. For example, see <a href="http://msdn.microsoft.com/en-us/library/tz8csy73.aspx" rel="noreferrer"><code>XmlSerializer.Deserialize Method (XmlReader)</code></a></p> <p>The <code>InvalidOperationException</code> will contain more details about the specific error in its <code>InnerException</code> property.</p> <p>Edit:</p> <p>The <a href="http://msdn.microsoft.com/en-us/library/xc221bxx.aspx" rel="noreferrer"><code>XmlSerializer.Deserialize Method (XmlSerializationReader)</code></a> can throw a <code>NotImplementedException</code>, but it is an internal API and is not meant to be used by your code, so don't worry about it.</p> <p>Edit 2:</p> <p>This code:</p> <pre><code>var ms = new System.IO.MemoryStream(); var deser = new System.Xml.Serialization.XmlSerializer(typeof(string)); deser.Deserialize(ms); </code></pre> <p>throws:</p> <pre><code>System.InvalidOperationException: There is an error in XML document (0, 0). --- System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) ... &lt;snip&gt; ... </code></pre> <p>So it really looks like the framework will always throw an <code>InvalidOperationException</code>.</p> <p>Really, unless you're worried about mistakenly catching exceptions like <code>ThreadAbortException</code>, you are probably safest catching <em>all</em> exceptions...</p> <p>Edit 3:</p> <p>Using <a href="http://www.red-gate.com/products/reflector/" rel="noreferrer">Reflector</a>: The <code>Deserialize(stream)</code> method reads the stream using an <code>XmlTextReader</code> and calls the <a href="http://msdn.microsoft.com/en-us/library/dk9cbaf1.aspx" rel="noreferrer"><code>XmlSerializer.Deserialize Method (XmlReader, String)</code></a>. That method throws an <code>InvalidOperationException</code> on error (according to the docs).</p> <p>Edit 4:</p> <p><code>Deserialize(stream)</code> can also throw a <code>NullReferenceException</code> if <code>stream</code> is null, because it calls the <a href="http://msdn.microsoft.com/en-us/library/cssfs8c4.aspx" rel="noreferrer"><code>XmlTextReader(Stream)</code></a> constructor.</p>
 

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