title: Validation of .NET assemblies in C#?
body: <p>How do you check if a assembly loaded is a valid .NET assembly? I currently have this code but unmanaged DLL's throw a BadImageFormatException.</p>
  <pre class="lang-cs prettyprint-override"><code>string[] filepaths = Directory.GetFiles(Directory.GetCurrentDirectory(), &quot;*.dll&quot;, SearchOption.AllDirectories);
  List&lt;Type&gt; potentialEffects = new List&lt;Type&gt;();
  
  foreach (string filepath in filepaths)
  {
      Assembly a = Assembly.LoadFile(filepath);
      potentialEffects.AddRange(a.GetTypes());
  }
  </code></pre>