Okay, so I just ran into the next problem that raised an eyebrow.
For various reasons, I have a test setup where the test classes in TestingAssembly.dll depend on the TestingBase class in BaseTestingAssembly.dll. One of the tasks that TestBase performs is finding a specific built-in resource in its own and calling assembly.
So my BaseTestingAssembly contained the following lines ...
public class TestBase { private static Assembly _assembly; private static Assembly _calling_assembly; static TestBase() { _assembly = Assembly.GetExecutingAssembly(); _calling_assembly = Assembly.GetCallingAssembly(); } }
Static, because I realized that these assemblies will be the same throughout the life of the application, so why bother with recounting them in each individual test.
While doing this, however, I noticed that both _assembly and _calling_assembly are set to BaseTestingAssembly, not BaseTestingAssembly and TestingAssembly respectively.
Setting the variables to non-static and initializing them in the regular constructor fixed this, but I'm confused why this happened to start this. I thought that static constructors are launched the first time a static member gets a reference. This can only be from my TestingAssembly, which was supposed to be caller. Does anyone know what could happen?
reflection c # static-constructor
George mauer
source share