问题
So I'm coming from a Python background and starting to get into C# and Mono on my Mac. I've just recently found the Mono CSharpRepl tool and would like to use it to achieve a similar workflow that I have in Python which includes repeatedly invoking 'reload(module)' as I fix errors in my Python code. Does Mono's CSharpRepl have similar functionality? Currently I've just been quitting, restarting, and then invoking 'LoadAssembly()' and 'using' statements again which is a pain.
回答1:
$ csharp
Mono C# Shell, type "help;" for help
Enter statements below.
csharp> var dom = AppDomain.CreateDomain("tmp");
csharp> dom.Load("System.Core");
System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
csharp> AppDomain.Unload(dom);
csharp>
This will do what you want, I presume
回答2:
I'm afraid this might be tricky, .Net has no way to unload an assembly apart from discarding whole AppDomain - which probably won't be any easier than restarting CSharpRepl.
来源:https://stackoverflow.com/questions/5585087/can-i-reload-an-assembly-in-mono-csharprepl