'Private Object "Attempted to access a missing member" exception

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



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rob Sedgwick