Errors with Python.Net 2.0 SP 1
Getting the following exception when attempting to bind a python delegate to an event handler. Has anyone come across this before? Unhandled Exception: System.TypeInitializationException: The type initializer for 'Python.Runtime.CodeGenerator' threw an exception. ---> System.InvalidCastException: Unable to cast object of type 'System.Reflection.Module' to type 'System.Reflection.Emit.ModuleBuilder'. at System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule() at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) at System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) at Python.Runtime.CodeGenerator..cctor() in C:\workspace2\Python.Net\runtime\codegenerator.cs:line 37 --- End of inner exception stack trace --- at Python.Runtime.DelegateManager.GetDispatcher(Type dtype) in C:\workspace2\Python.Net\runtime\delegatemanager.cs:line 79 at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr callable) in C:\workspace2\Python.Net\runtime\delegatemanager.cs:line 168 at Python.Runtime.EventObject.AddEventHandler(IntPtr target, IntPtr handler) in C:\workspace2\Python.Net\runtime\eventobject.cs:line 49 at Python.Runtime.EventBinding.nb_inplace_add(IntPtr ob, IntPtr arg) in C:\workspace2\Python.Net\runtime\eventbinding.cs:line 44 Here is a simple script that demonstrates this error
from System.Windows.Forms import Application
def global_exception_handler(sender, event_args): print "GOT AN EXCEPTION" print event_args.Exception Application.ThreadException += global_exception_handler
participants (1)
-
Maksim Kozyarchuk