Hey all, so I'm looking for a way to call a method in an application externally from a dll. (see example below) This is what I'm trying however it's a) not working and b) if it was working i have a feeling that calling DynamicInvoke is going to be painfully slow.

first all if I did want to do it this way how do I deal with returns types as currently this will errors saying callthisexternally() has wrong return type.

is there a better way to do this?

--- within a a dll ---
public class mydll
    // etc.. blah blah

    public object callfromdll(string commandName, int requiredArgs, Delegate method)
        // do stuff

        // now invoke the method
        return method.DynamicInvoke(method.Method.GetParameters().Select(p => p.ParameterType).ToArray());


-- within an application that's refrancing the above dll --
public someclass
    // etc.. stuff here
    mydll m = new mydll();
    m.callfromdll("callthisexternally", 0, new Action(callthisexternally));

    // the function to be called externally
    public string callthisexternally()
        // do stuff
        return "i was called!";
4 Years
Discussion Span
Last Post by Ketsuekiame
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.