ConstructorInfo con1 = typeof (A).GetConstructor (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type [1] { typeof (int) }, null);
ConstructorInfo con2 = typeof (B).GetConstructor (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type [1] { typeof (int) }, null);
- con1.Invoke (null, new Object [] { 0 });
- con2.Invoke (null, new Object [] { 0 });
+ con1.Invoke (new Object [] { 0 });
+ con2.Invoke (new Object [] { 0 });
// Test what happens when static initialization throws an exception
// First start a thread which will trigger the initialization
// While the thread waits, trigger initialization on this thread too so this
// thread will wait for the other thread to finish initialization
try {
- Run ();
+ Run2 ();
return 1;
}
catch (TypeInitializationException ex) {
// Try again synchronously
try {
- Run ();
+ Run2 ();
return 1;
}
catch (TypeInitializationException ex) {
}
private static void Run () {
+ try {
+ StaticInitFails.foo ();
+ }
+ catch (Exception) {
+ }
+ }
+
+ private static void Run2 () {
StaticInitFails.foo ();
}
+
}