If the method is not static, you need to pass a reference to an instance of the class whose method you are going to use using the delegate.
If you do not know which instance you will be using at the time you are trying to create the delegate, you will need to save the type and method information later, and then create the delegate after you have an instance of the class.
EDIT
To respond to your comment, the object you need to pass is an object of the type that contains the method to which you are trying to bind your delegate. Therefore, based on your sample code, this is not a Command object, but a class object from a DLL.
So let's say that you have this .NET assembly. DLL: myassembly.dll . The assembly contains the following class:
namespace MyNamespace { public class SomeClass { public SomeClass() { } public void Method1(object Command, object ExposedVariables) { } public void Method2(object Command, object ExposedVariables) { } }
You will need to instantiate the SomeClass class before you can create the delegates associated with Method1 or Method2 of this class. So, the code that the delegate creates should look like this:
// assuming that method info is a MethodInfo contains information about the method // that you want to create the delegate for, create an instance of the class which // contains the method.. object classInstance = Activator.CreateInstance(methodInfo.DeclaringType); // and then create the delegate passing in the class instance Delegate.CreateDelegate(typeof(Command.delCmdMethod), classInstance, methodInfo);
source share