Reflection and static constructors

  • Thread starter Thread starter Dansk
  • Start date Start date
D

Dansk

Hi all,

I have a class with a static constructor that I need to call via reflection.

I've tried lots of combinations with the binding flags and InvokeMethod,
no luck so far.

Do you have any suggestion?

Thanks in advance,
Dansk.
 
Sorry for disturbing, I finally have it:

ConstructorInfo constructorInfo =
type.GetConstructor(BindingFlags.Static | BindingFlags.NonPublic, null,
new Type[0], null);
constructorInfo.Invoke(null, null);


Dansk a écrit :
 
Sorry for disturbing, I finally have it:

ConstructorInfo constructorInfo =
type.GetConstructor(BindingFlags.Static | BindingFlags.NonPublic, null,
new Type[0], null);
constructorInfo.Invoke(null, null);

Or rather simpler: type.TypeInitializer.

Jon
 
Back
Top