title: Assembly.GetCallingAssembly() and static constructors?
body: <p>Ok, so I just ran into the following problem that raised an eyebrow.</p>
  
  <p>For various reasons I have a testing setup where Testing classes in a TestingAssembly.dll depend on the TestingBase class in a BaseTestingAssembly.dll.
  One of the things the TestBase does in the meantime is look for a certain embedded resource in its own and the calling assembly</p>
  
  <p>So my BaseTestingAssembly contained the following lines...</p>
  
  <pre><code>public class TestBase {    
    private static Assembly _assembly;
    private static Assembly _calling_assembly;
  
    static TestBase() {
      _assembly = Assembly.GetExecutingAssembly();
      _calling_assembly = Assembly.GetCallingAssembly();
    }
  }
  </code></pre>
  
  <p>Static since I figured, these assemblies would be the same over the application's lifetime so why bother recalculating them on every single test.</p>
  
  <p>When running this however I noticed that both _assembly and _calling_assembly were being set to BaseTestingAssembly rather than BaseTestingAssembly and TestingAssembly respectively.</p>
  
  <p>Setting the variables to non-static and having them initialized in a regular constructor fixed this but I am confused why this happened to begin this.  I thought static constructors run the first time a static member gets referenced.  This could only have been from my TestingAssembly which should then have been the caller.  Does anyone know what might have happened?</p>