I am working on a project using .Net mvc. I have a csharp class containing both a static constructor and some static filed.
private static Class1 obj1 = new Class1();
private static Class2 obj2 = new Class2();
static Foo()
{
Init();
}
private static void Init()
{
obj1.DoSomething();
obj2.DoSomething();
}
This class is part of my DomainModel, and is referenced in my Controller code. When I run the project with VS2008. It seems Init() is called before the Controller code uses obj1 and obj2. But when I deploy the code to a virtual server, Init() seems not being called at all. Is there any way to guarantee the execution order of these methods?