c# - How to ensure that a static constructors is called without calling any member -


i have class static constructor.

i want static constructor called without calling or using of members, if constructor has not been called already.

i tried using reflection. reflection can invoke static constructor (many times), cannot find out if has been called before.

how do this?

edit
not 1 class talking about, more. lets say, classes marked special attribute.

you can use runtimehelpers.runclassconstructor method (assuming correctly understood trying do...)

runtimehelpers.runclassconstructor(typeof(yourtype).typehandle); 

Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -