title: Loading an assembly generated by the Roslyn compiler
body: <p>I'm generating a Greeter.dll using the Roslyn compiler. My problem occurs trying to load the DLL file. </p>
  
  <p>Here's the code:</p>
  
  <pre><code>using System;
  
  using Roslyn.Compilers;
  using Roslyn.Compilers.CSharp;
  
  using System.IO;
  using System.Reflection;
  using System.Linq;
  
  namespace LoadingAClass
  {
      class Program
      {
          static void Main(string[] args)
          {
              var syntaxTree = SyntaxTree.ParseCompilationUnit(@"
  class Greeter
  {
      static void Greet()
      {
          Console.WriteLine(""Hello, World"");
      }
  }");
  
              var compilation = Compilation.Create("Greeter.dll",
                  syntaxTrees: new[] { syntaxTree },
                  references: new[] {
                      new AssemblyFileReference(typeof(object).Assembly.Location),
                      new AssemblyFileReference(typeof(Enumerable).Assembly.Location),
                  });
  
              Assembly assembly;
              using (var file = new FileStream("Greeter.dll", FileMode.Create))
              {
                  EmitResult result = compilation.Emit(file);
              }
  
              assembly = Assembly.LoadFile(Path.Combine(Directory.GetCurrentDirectory(), @"Greeter.dll"));
              Type type = assembly.GetType("Greeter");
              var obj = Activator.CreateInstance(type);
  
              type.InvokeMember("Greet",
                  BindingFlags.Default | BindingFlags.InvokeMethod,
                  null,
                  obj,
                  null);
  
              Console.WriteLine("&lt;ENTER&gt; to continue");
              Console.ReadLine();
  
          }
      }
      // Thanks, http://blogs.msdn.com/b/csharpfaq/archive/2011/11/23/using-the-roslyn-symbol-api.aspx
  }
  </code></pre>
  
  <p>The error message occurs on the line <code>assembly = Assembly.LoadFile(Path.Combine(Directory.GetCurrentDirectory(), @"Greeter.dll"));</code> and reads </p>
  
  <blockquote>
    <p>Im Modul wurde ein Assemblymanifest erwartet. (Ausnahme von HRESULT: 0x80131018)</p>
  </blockquote>
  
  <p>Which roughly translates to </p>
  
  <blockquote>
    <p>An assembly manifest was expected in the module. </p>
  </blockquote>
  
  <p>Does anyone know what I'm missing here?</p>