C#: How to make a method call on a static member of an existing object
<p>So I'm performing tests on a dll with the following:</p>

<pre><code>--test.dll--
namespace MyNamespace
{
    internal class foo
    {
        private static bar myBarClass = new bar();
    ]

    internal class bar
    {
        public void aMethod();
    }
}
----
</code></pre>

<p>Now in another program I have an existing instance of foo (obtained via reflection).  Now I want to call the method aMethod() from the myBarClass within the existing instance of foo.  Not sure how to do this.</p>

<pre><code>foo myFooObject = GetInstanceOfFoo();  //i get an instance of foo via reflection

Assembly testAssembly= Assembly.LoadFrom(c:\test.dll);
object o = testAssembly.CreateInstance("MyNamespace.bar");
Type t = o.GetType();
BindingFlags bf = BindingFlags.Instance | BindingFlags.NonPublic;
MethodInfo mi = t.GetMethod("aMethod", bf);
mi.Invoke(&lt;notsurewhatgoeshere!&gt;, null);
</code></pre>

<p>I am able to get the correct method info. My question is in mi.Invoke, how to I invoke the method on the already existing instance of foo.bar?</p>

<p>Thanks</p>
