chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes


I found a few similar post back days for 2 years.

Just want to double check if there's any solution to by now or we still need to use reflection to invoke the private static method that has ref param ?


TypeMock.TypeMockException : 
*** Could not invoke DummyClass.DummyStaticMethod:
No overloads of method "DummyStaticMethod" receive argument types {Boolean}
Possible candidates are:
- DummyStaticMethod(Boolean&)
asked by cscmh99 (6.1k points)

1 Answer

+1 vote

This feature was added since then.

Basically you should wrap the ref parameters with IBox<T> interface as you can see in teh example below:

public class Foo
    private static int DoSomething(ref int x)
        x = 13;
        return 0;

public void InvokingPrivateStaticMethodsWithRef()
    IBox<int> val1 = Args.Ref(10);
    Isolate.Invoke.Method<Foo>("DoSomething", val1);

    Assert.AreEqual(13, val1.Value);


See documentation for more info.



answered by alex (17k points)