IronLanguages / ironpython2

Implementation of the Python programming language for .NET Framework; built on top of the Dynamic Language Runtime (DLR).
http://ironpython.net
Apache License 2.0
1.08k stars 229 forks source link

When hooking the AssemblyResolve function in a secondary AppDomain, IPY throws a StandardError #594

Open byt3bl33d3r opened 5 years ago

byt3bl33d3r commented 5 years ago

Description

When hooking the AssemblyResolve function in a secondary AppDomain, IPY throws a StandardError

Steps to Reproduce

This was done directly in the IPY interepreter

>>> from System import AppDomain
>>> def handler(s,e):
...         return None

>>> AppDomain.CurrentDomain.AssemblyResolve += handler # this works

>>> ad = AppDomain.CreateDomain("test")
>>> ad.AssemblyResolve += handler # this doesn't 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StandardError: Exception has been thrown by the target of an invocation.

Versions

IronPython 2.7.9 2.7.9.0 on .NET 4.0.30319.42000

slozier commented 5 years ago

Haven't got a clue about this one... Here's the .NET trace:

>>> AppDomain.add_AssemblyResolve(ad, handler)
Cannot serialize delegates over unmanaged function pointers, dynamic methods or methods outside the delegate creator's assembly.
   at System.MulticastDelegate.GetObjectData(SerializationInfo info, StreamingContext context)
   at System.Runtime.Serialization.ObjectCloneHelper.GetObjectData(Object serObj, String& typeName, String& assemName, String[]& fieldNames, Object[]& fieldValues)
   at System.AppDomain.add_AssemblyResolve(ResolveEventHandler value)
   at Microsoft.Scripting.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run5[T0,T1,T2,T3,T4,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   at Microsoft.Scripting.Interpreter.FuncCallInstruction`7.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run5[T0,T1,T2,T3,T4,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   at IronPython.Compiler.Ast.CallExpression.Invoke2Instruction.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   at IronPython.Hosting.PythonCommandLine.<>c__DisplayClass27_0.<RunOneInteraction>b__0()