0

I am trying to invoke a private method of an object using private method. This method takes three arguments. Both signature of method i am trying to invoke and the code invoking this method are shown below

Signature of private method:

Public Class Foo
{
  private void SaveCallback(SaveAggregationViewResponse response,
                                         Action rollbackActionIfSaveFails,
                                         Action postSaveActionOnSuccess)
  {}
}

Code I am using to invoke method:

var foo=new Foo()
Private pFoo=new PrivateObject(foo);
var response=new SaveAggregationViewResponse();
pFoo.Invoke("SaveCallback",new object[]{response,(Action)null,(Action)null}); //this line throws exception

Exception Message: Method 'Foo.SaveCallback' not found.

Is there something wrong with the way I am invoking private method or some other setup is wrong?

Thank You

Jim Counts
  • 12,535
  • 9
  • 45
  • 63
Rahul Lodha
  • 3,601
  • 7
  • 25
  • 34

1 Answers1

0

Try calling it with a ParamArray instead of an array of objects

pFoo.Invoke("SaveCallback",response,null,null);

Not sure whether to include the nulls, get rid of them if it doesn't work.

Rob Sedgwick
  • 4,342
  • 6
  • 50
  • 87