Hi, I have following class (as seen through reflector)
public class W : IDisposable
{
public W(string s);
public W(string s, byte[] data);
// more constructors
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern W(string s, int i);
public static W Func(string s, int i);
}
I am trying to call "internal extern" constructor or Func using reflections
MethodInfo dynMethod = typeof(W).GetMethod("Func", BindingFlags.Static);
object[] argVals = new object[] { "hi", 1 };
dynMethod.Invoke(null, argVals);
and
Type type = typeof(W);
Type[] argTypes = new Type[] { typeof(System.String), typeof(System.Int32) };
ConstructorInfo dynMethod = type.GetConstructor(BindingFlags.InvokeMethod | BindingFlags.NonPublic, null, argTypes, null);
object[] argVals = new object[] { "hi", 1 };
dynMethod.Invoke(null, argVals);
unfortunantly both variants rise NullReferenceException when trying to Invoke, so, I must be doing something wrong?