[Mono-list] Reflection odd exception

Elliott Draper el at eldiablo.co.uk
Wed Oct 19 06:42:57 EDT 2005


I'd hazard a guess and say it's because you don't have a reference to 
the relevant Gdk assemblies, or they can't be found in the path, gac 
etc. As such when it's creating this object, it's coming unstuck because 
that class is using a type that it can't find, hence when you change it 
to using types it can find (object, EventArgs), there's no problem.

Either way, you can check the inner exception of that exception to get 
the exact error. It'll tell you in there what the problem is, and 
whether it is in fact a problem with the call using that type, or 
whether I'm way off the mark and it's something completely different :-)

Let me know how you get on.

Cheers,
-= El =-

Carlos Ble wrote:

>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
>
>
>_______________________________________________
>Mono-list maillist  -  Mono-list at lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-list
>  
>



More information about the Mono-list mailing list