Reputation: 3721
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
Upvotes: 0
Views: 12951
Reputation: 4514
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.
Upvotes: 0