tags:

views:

14

answers:

1

Hi, I have coverted project to .Net 4.0 and folowing code doesn't work:

typeof(RuntimeTypeHandle).GetMethod("Allocate", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(type.TypeHandle, null)

It seems that there is no more Allocate method in RuntimeTypeHandle class. GetMethod returns null.

What is the analog in .Net 4.0?

+1  A: 

The new version method signature is:

internal static extern object Allocate(RuntimeType type);

So I guess you just need to make BindingFlags.Static (instead of Instance).

Your invocation will be slightly different too.

leppie