Can I reload an assembly in Mono CSharpRepl?

2019-05-05 08:58发布

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.

标签: c# mono
2条回答
戒情不戒烟
2楼-- · 2019-05-05 09:21

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.

查看更多
相关推荐>>
3楼-- · 2019-05-05 09:35
$ 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

查看更多
登录 后发表回答