[Mono-list] Reflection odd exception

Carlos Ble carlosble at shidix.com
Wed Oct 19 06:37:23 EDT 2005


Hi!
Iam working with reflection by loading some clases dinamically. This is
a piece of "pseudo" code:
System.Object[] paramsObj = new System.Object[] {...params...};
Assembly assembly = Assembly.GetExecutingAssembly();
System.Object childWin =       
  AppDomain.CurrentDomain.CreateInstanceAndUnwrap(assembly.FullName,    
  managerClass,true, BindingFlags.Instance|BindingFlags.Public,
  null, paramsObj, null, null, null);

Everything works fine but one of the classes to load has this method:

bool OnWinDeleteEvent (Gdk.Event e) // Instead of (object o, EventArgs
e).
{
  ...
  return true;
}

I can compile all successfull but in runtime, CreateInstanceAndUnwrap
call launchs this exception: 

Exception has been thrown by the target of an invocation.
in <0x0010e> System.Reflection.MonoCMethod:Invoke (System.Object obj,
BindingFlags invokeAttr, System.Reflection.Binder binder,
System.Object[] parameters, System.Globalization.CultureInfo culture)
in <0x0001c> System.Reflection.MonoCMethod:Invoke (BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture)
in <0x00200> System.Activator:CreateInstance (System.Type type,
BindingFlags bindingAttr, System.Reflection.Binder binder,
System.Object[] args, System.Globalization.CultureInfo culture,
System.Object[] activationAttributes)
in <0x0005b> System.Activator:CreateInstance (System.String
assemblyName, System.String typeName, Boolean ignoreCase, BindingFlags
bindingAttr, System.Reflection.Binder binder, System.Object[] args,
System.Globalization.CultureInfo culture, System.Object[]
activationAttributes, System.Security.Policy.Evidence securityInfo)
in <0x0002d> System.AppDomain:CreateInstance (System.String
assemblyName, System.String typeName, Boolean ignoreCase, BindingFlags
bindingAttr, System.Reflection.Binder binder, System.Object[] args,
System.Globalization.CultureInfo culture, System.Object[]
activationAttributes, System.Security.Policy.Evidence
securityAttributes)
in (wrapper remoting-invoke-with-check) System.AppDomain:CreateInstance
(string,string,bool,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[],System.Security.Policy.Evidence)
in <0x0002e> System.AppDomain:CreateInstanceAndUnwrap (System.String
assemblyName, System.String typeName, Boolean ignoreCase, BindingFlags
bindingAttr, System.Reflection.Binder binder, System.Object[] args,
System.Globalization.CultureInfo culture, System.Object[]
activationAttributes, System.Security.Policy.Evidence
securityAttributes)
in (wrapper remoting-invoke-with-check)
System.AppDomain:CreateInstanceAndUnwrap
(string,string,bool,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[],System.Security.Policy.Evidence)

If I change arguments to (object o, EventArgs e), it works fine. Can
somebody write some comments about this behaviour?.

Thanks




More information about the Mono-list mailing list