Why doesn’t the CLR always call value type constructors

The Microsoft C#4 Spec has changed slightly from previous versions and now more accurately reflects the behaviour that we’re seeing here: 11.3.10 Static constructors Static constructors for structs follow most of the same rules as for classes. The execution of a static constructor for a struct type is triggered by the first of the following … Read more

Why would finding a type’s initializer throw a NullReferenceException?

with csc test.cs: (196c.1874): Access violation – code c0000005 (first chance) mscorlib_ni!System.RuntimeType.GetConstructorImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Reflection.CallingConventions, System.Type[], System.Reflection.ParameterModifier[])+0xa3: 000007fe`e5735403 488b4608 mov rax,qword ptr [rsi+8] ds:00000000`00000008=???????????????? Trying to load from [rsi+8] when @rsi is NULL. Lets inspect the function: 0:000> ln 000007fe`e5735403 (000007fe`e5735360) mscorlib_ni!System.RuntimeType.GetConstructorImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Reflection.CallingConventions, System.Type[], System.Reflection.ParameterModifier[])+0xa3 0:000> uf 000007fe`e5735360 Flow analysis was incomplete, some code may … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)