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.
Asked
Active
Viewed 1,133 times
2 Answers
5
$ 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

sehe
- 374,641
- 47
- 450
- 633
-
I could work with this except I've tried loading my own assembly and csharp comes back with a System.IO.FileNotFoundException. Then tried to load System.Collections into dom and I get the same error. System.Core is the only thing I've been able to load so far. Any suggestions? – spade78 Apr 08 '11 at 02:57
-
Looks like the C# Nutshell book covers AppDomain. Think I know why I'm getting the System.IO.FileNotFoundException. Will read further and work on it. – spade78 Apr 08 '11 at 03:12
-
@spae: cheers! You can also use `AppDomain.AssemblyResolve` [MSDN](http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve(v=VS.100).aspx) to fix your bind. All this is known territory for Javans, Pythonists etc. – sehe Apr 08 '11 at 06:46
1
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.

skolima
- 31,963
- 27
- 115
- 151