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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -