title: AssemblyResolve not fired for dependencies
body: <p>I'm struggling with AssenblyResolve event for a while now. I've searched stackoverflow and did other googling and tried all that I think was relevant. Here are the links being the closer to my problem (in my opinion) :</p>
  
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/6493371/assemblyresolve-is-not-invoked-and-filenotfoundexception-is-thrown-during-serial">AssemblyResolve is not invoked and FileNotFoundException is thrown during serialization</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/9099309/where-to-handle-assemblyresolve-event-in-a-class-library">Where to handle AssemblyResolve event in a class library?</a></p></li>
  </ol>
  
  <p>I have a Bootstrapper class with to static method (I will remove the thread safe code that we have, just for the sake of clarity :</p>
  
  <pre><code>public static void Initialize()
  {
      AppDomain.CurrentDomain.AssemblyResolve += CustomResolve;
  }
  
  private static Assembly CustomResolve(object sender, ResolveEventArgs args)
  {
      // There is a lot code here but basicall what it does.
      // Is determining which architecture the computer is running on and
      // extract the correct embedded dll (x86 or x64). The code was based
      // on milang on GitHub (https://github.com/milang/P4.net). And it's the same
      // purpose we want to be able to load the x86 or x64 version of the perforce dll
      // but this time with the officially Perforce supported p4api.net.
      // Once the dll is extracted we assign it to the boostrapper
      Bootstrapper._p4dnAssembly = Assembly.LoadFile(targetFileName);
  
      // Make sure we can satisfy the requested reference with the embedded assembly (now extracted).
      AssemblyName reference = new AssemblyName(args.Name);
      if (AssemblyName.ReferenceMatchesDefinition(reference, Bootstrapper._p4dnAssembly.GetName()))
      {
          return Bootstrapper._p4dnAssembly;
      }
  }
  </code></pre>
  
  <p>I was able to make the code work if the I have simple class with a main method and static constructor. The static constructor is simply calling the Boostrapper.Initialize() method.
  After that, I could use my library and it was working as expected :</p>
  
  <pre><code>public static class Test
  {
      static Test()
      {
          Bootstrapper.Initialize();
      }
  
      public static void Main()
      {
           // Using the library here is working fine. The AssemblyResolve event was
           // fired (confirmed by a breakpoint in Visual Studio)
      }
  }
  </code></pre>
  
  <p>The problem I have is if there is at least one layer of dependency. Basically the code stays the same but this time my the code of the library is inside another library :</p>
  
  <pre><code>public static class Test
  {
      static Test()
      {
          Bootstrapper.Initialize();
      }
  
      public static void Main()
      {
          Class1 myClass = new Class1();
  
          // The following line is using the code of the extracted library, but
          // The AssemblyResolve event is not fired (or fired before I register the  
          // callback) and therefore the library is not found : result  
          // BadImageFormatException() error could not load libary because one
          myClass.Connect();
      }
  }
  </code></pre>
  
  <p>Sounds like #2 of the links I've previously stated explain what I'm seeing but it does not work. Visual Studio break point on the AssemblyResove callback is never being hit.</p>
  
  <p>Any idea of what's going on?</p>
  
  <p>Francis</p>