I would like to use IronPython to override a method from a dll, so that all future calls to that method go to the python implementation instead. I was hoping to base it on the technique from the accepted answer here.
So I tried making a dll with just 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 running the 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 any way to accomplish what I am looking for?