title: not throwing an exception when missing reference on deserialize
body: <p>I am writing an agnostic viewer for a collection of systems that I'm working with. This viewer will show me the generic structure of my data without needing to know the context of the specific system.</p>
  
  <p>I'm trying to deserialise a memory stream which contains only a type <code>Foo&lt;T&gt;</code> where <code>Foo&lt;T&gt;</code> inherits from <code>Foo</code>. From the agnostic viewers point of view, all the data that I require is in Foo. The <code>&lt;T&gt;</code> part is irrelevant.</p>
  
  <p>Type T is defined in another assembly(s). Under normal operation, the system obviously has all appropriate contextual assemblies loaded. The problem is that when running the viewer, none of the contextual assemblies are loaded. when I attempt to deserialise the instance of Foo, I obviously get an exception because the referenced assembly is not loaded. </p>
  
  <p>I'm trying to detect whether or not I have all required referenced assemblies loaded and thus know whether to try to deserialise the data, or reconstruct the data that I require from other aspects of the class.</p>
  
  <p>I know I can do this using a very simple exception try/ catch block, but, this is not an exception case. I <I>know</I> this is going to happen hundreds, if not thousands of times when I load my data, and this could cause me a nightmare, as I like to have break on exception turned on. I also subscribe to the school of thought that says "Exception - the hint is in the name" and thus Exceptions should not form part of your primary case code.</p>
  
  <p>--------edit 21/10/2013------------</p>
  
  <p>see <a href="https://www.dropbox.com/s/ina3g0r2y08sgsq/TemplatedSerialisationProblem.rar" rel="nofollow">here</a> for a full illustrative example, but here are the important bits:</p>
  
  <p>Foo class, defined in common:</p>
  
  <pre><code>[Serializable]
  public class Foo
  {
      public string Agnostic { get; set; }
  }
  
  [Serializable]
  public class Foo&lt;T&gt; : Foo
  {
      public string Contextual { get; set; }
  }
  </code></pre>
  
  <p>Contextual saving: </p>
  
  <pre><code>BinaryFormatter bf = new BinaryFormatter();
  FileInfo tempFile = TempFileGetter.GetTempFile();
  
  
  Foo&lt;Bar&gt; fooBar = new Foo&lt;Bar&gt;();
  fooBar.Agnostic = "Agnostic";
  fooBar.Contextual = "Contextual";
  
  
  using (var fs = tempFile.OpenWrite())
  {
     bf.Serialize(fs, fooBar);
     fs.Flush();
  }
  </code></pre>
  
  <p>Agnostic loading:</p>
  
  <pre><code>BinaryFormatter bf = new BinaryFormatter();
  FileInfo tempFile = TempFileGetter.GetTempFile();
  
  using (var fs = tempFile.OpenRead())
  {
     Foo foo = (Foo)bf.Deserialize(fs);
     Controls.DataContext = foo;
  }
  </code></pre>
  
  <p>I mean, there is nothing rocket science in this code, and, if the "agnostic" viewer loads the context viewer as a reference, then it loads fine, but, I don't want to do this, as we won't always have the the contextual libraries to load.</p>