0

Method:

  private static HipKvp[] GetRequestParameterArray(CaptchaRequestModel request){}

Unit Test:

  HipKvp[] input = (HipKvp[])privObj.Invoke("GetRequestParameterArray", new CaptchaRequestModel[] { result });

Exception:

MissingMethodException was unhandled by user code:
Attempted to access a missing member.

I've tried different ways, but not working.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • Know [to work](http://stackoverflow.com/questions/8609595/using-privateobject-invoke-to-call-a-static-conversion-function-do-not-compile-i). Check spelling and object type. – Hans Passant Mar 13 '13 at 04:06
  • http://stackoverflow.com/questions/5396996/how-can-i-use-privateobject-to-access-private-members-of-both-my-class-and-its-p Check this link - and try passing binding flags; –  Aug 04 '13 at 20:48

1 Answers1

0

PrivateObject.Invoke(String, Object[]) does not touch static members, probably because the members don't necessarily belong to the object, but to the class.

You need to use PrivateObject.Invoke(String, BindingFlags, Object[]) and specify BindingFlags.NonPublic | BindingFlags.Static in the second parameter like so:

HipKvp[] input = (HipKvp[])privObj.Invoke("GetRequestParameterArray", BindingFlags.NonPublic | BindingFlags.Static, new CaptchaRequestModel[] { result });
Mingling94
  • 13
  • 1
  • 4