Example

using System;
using System.IO;
using System.Reflection;

namespace Samples
{
  public class FileLoadExceptionSample
  {
    public static void Main()
    {
      try
      {
        Assembly a = Assembly.LoadFrom(
                         "ModuleOnly.netmodule");
        Console.WriteLine(a.Location);
      }
      catch(FileLoadException e)
      {
        Console.WriteLine("Exception: {0}", e);
      }
    }
  }
}
The output is
 Exception: System.IO.FileLoadException: The module 'ModuleOnly.netmodule' was expected to contain an assembly manifest. File name: "ModuleOnly.netmodule" at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark) at System.Reflection.Assembly.InternalLoad(AssemblyName ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.