Ashif Nataliya
Ashif Nataliya

Reputation: 922

InvokeMember call is throwing MissingMethodException

I am invoking one of the functions from assembly but I am getting MissingMethodException. I have open exe in .netreflector and show that function is available at right place though it is giving error. Here is the code.

private void button2_Click(object sender, EventArgs e)
 {
        Assembly obj = Assembly.LoadFrom("Solo4O.exe");
        Type datacrypt = obj.GetType("Orch.DC");

        object[] objects = new object[3];

....

        datacrypt.InvokeMember("GetCryptedXML", BindingFlags.InvokeMethod |
                                                BindingFlags.Static |
                                                BindingFlags.Public,
                               null, datacrypt, objects, null);

}

Upvotes: 0

Views: 2740

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500145

Your target argument is datacrypt but it should be null, as you're calling a static method (and you're definitely not calling a method on datacrypt).

Beyond that, it's hard to know exactly what's wrong, partly because you haven't shown how you've initialized objects... we don't know what the types involved are. Please show more code. I strongly suspect that one of your argument types is invalid for the method call.

Upvotes: 3

Related Questions