I would like to use IronPython to override the method from the dll, so that all future calls to this method go to the python implementation. I was hoping to base it on a technique from the accepted answer here .
So, I tried to make a dll with only the following class:
namespace ClassLibrary1
{
public class Class1
{
public static string test()
{
return "test";
}
}
}
Then I did the following in IronPython:
import clr
clr.AddReference("ClassLibrary1")
import ClassLibrary1
def _override():
return "george"
ClassLibrary1.Class1.test = _override;
print ClassLibrary1.Class1.test();
However, when I run python code, I get the following exception:
An exception of type 'System.MissingMemberException' occurred in Snippets.debug.scripting but was not handled in user code
Additional information: attribute 'test' of 'Class1' object is read-only
Is there a way to accomplish what I'm looking for?
source
share