title: How should I force load a referenced assembly?
body: <p>I have a third-party library that requires an assembly A to be loaded when I call into their code. That assembly is typically installed in the GAC, so I have several options to load it:</p>
  
  <ol>
  <li>I can explicitly call <code>Assembly.Load()</code>. However that requires the full name which I don't feel comfortable to hard code in my program. </li>
  <li>I can explicitly call <code>Assembly.LoadWithPartialName()</code>. That is an obsolete API of course, and of course I don't feel comfortable to lose control in versioning.</li>
  <li>I can reference the assembly in my Visual Studio project file, so I always get the version I built against. However, that won't work unless I create a dummy object in that assembly. The C# compiler simply ignores it if I don't.</li>
  <li>Same problem if I call <code>Assembly.GetReferencedAssemblies</code> and force load the matched one. The C# compiler simply won't reference my assembly even if I put it in the references list.</li>
  </ol>
  
  <p>Now what I'm doing is to call <code>typeof(A.Foo).Assembly.GetName()</code> and ignore the return value. Is there a better way to do it?</p>