2
IronPython에서 처리 할 수있는 C# 이벤트 처리기를 어떻게 만듭니 까?IronPython에서 처리 할 수있는 C# 이벤트 처리기는 어떻게 만듭니 까?
IronPython 2.0.1을 사용하고 있습니다. 나는 문제없이 System 클래스에서 이벤트를 처리 할 수 있지만 (예 : Window.KeyDown) IronPython에서 후크하려고 시도 할 때 예외가 발생합니다.
Throw 된 예외는 ArgumentTypeException이며 "개인 이벤트에 추가 할 수 없습니다."라는 메시지가 있습니다. 내가 연결하려고하는 이벤트가 공개적이라고 생각하면 메시지가 이상하게 보입니다.
내 C# 클래스는 다음과 같습니다
class Foo
{
...
public event EventHandler Bar;
}
내 IronPython의 설치 코드는 다음과 같습니다
ScriptEngine engine = Python.CreateEngine();
ScriptRuntime runtime = engine.Runtime;
ScriptScope scope = runtime.CreateScope();
ScriptSource source = engine.CreateScriptSourceFromFile("Test.py");
Foo bar = new Foo();
scope.SetVariable("Foo", bar);
source.Execute(scope); <-- Exception is thrown here.
내 IronPython의 스크립트는 다음과 같습니다
이def BarHandler(*args):
pass
Foo.Bar += BarHandler
사람이 알고 있나요 이 일을 잘못한다면?
IronPython에 문제가 있습니까?