Can I reload an assembly in Mono CSharpRepl?

元气小坏坏 提交于 2019-12-22 08:23:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!