yes i had the same info but it fails at this step:
Delegate d = Delegate.CreateDelegate(tD
// i get an exception
// The best overloaded method match for 'System.Delegate.CreateDel
// if i do change the parameters it doesnt work
so far i have this:
Assembly cmdAssembly = Assembly.LoadFrom(script);
try
{
// We need to use reflection to use the correct handler
string cmdType = "CCScript."+clRow.CmdDLL.S
System.Type theType = cmdAssembly.GetType(cmdTyp
if(theType != null &&
theType.GetInterface ("Commander.IUI") != null &&
theType.GetInterface ("Commander.INonUI") != null
)
{
// create the constructor arguments
object[] args = {cmd};
// create the cmdHandler object
object cmdHandler = Activator.CreateInstance(t
// subscribe to the OutputCreated event handler
EventInfo evClick = theType.GetEvent("OutputCr
Type tDelegate = evClick.EventHandlerType;
MethodInfo miHandler =
typeof(CommandProcessor).G
BindingFlags.NonPublic | BindingFlags.Instance);
// this fails
// Delegate d = Delegate.CreateDelegate(tD
// this is ok but it doesnt work
Delegate d = Delegate.CreateDelegate(tD
MethodInfo addHandler = evClick.GetAddMethod();
Object[] addHandlerArgs = { d };
addHandler.Invoke(cmdHandl
// invoke the ConsumeMessage method of the handler
theType.InvokeMember ("ExecuteCommand",
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
cmdHandler,
args);
}
}
catch(Exception ex)
{
// there is a problem
returnCode = -1;
}
Regards,
Ready1
Main Topics
Browse All Topics





by: AlexFMPosted on 2006-08-06 at 06:36:36ID: 17258826
http://msdn2.microsoft.com /en-us/lib rary/ms228 976.aspx