I already have a working implementation that adds scripting to an application. The application currently generates and compiles scripts from C# snippets (taken from different user provides configuration files) into assemblies using the CodeDOM. As it sounded like a good idea at first I ran into following issues:

  1. difficult AppDomain handling and need for Serialization
  2. performance issue => frequent script changes trigger a recompilation
  3. changes cannot be made in-place in the scripts while running
  4. difficult to provide a GUI for debugging (breakpoints), the script writer actually needs a debugger...

I "hacked" a solution against 1 by loading everything in the main AppDomain. The problem is that nothing can be unloaded... After some time the memory use is huge.

For this reason I eventually would consider to switch to an interpreted solution but want to remain near to a C# language because of the existing code-base. There is a bunch of libs around Vsa, S#, Script.NET, ... I need to access objects in my application from the scripts and also run methods in the scripts from my application. Do you also think that switching to an interpreted language the right strategy or should I try to add a debug mode to the existing concept by injecting code like calling a method between each line of the script to allow a step by step execution.... However the AppDomain handling remains a nightmare to handle.

It is certainly not the first time someone runs in such a situation. I could not find any FOSS wrapper/helper library to make the CodeDOM handling easier nor GUI elements to provide building blocks for a minimal debugger. Currently I built ma own GUI and step over calls in the scripts and show changes in the application objects (before/after calls) inside the GUI.

Please only refer to FOSS source/libs.

  • Dupe of Roslyn? Commented Mar 2, 2012 at 16:29
  • 2
    Is there a reason you don't just use PowerShell? If your platform is Windows I would highly recommend it.
    – user37735
    Commented Mar 2, 2012 at 16:33
  • Why only FOSS libs? Or do you just mean free libs?
    – svick
    Commented Mar 2, 2012 at 16:41
  • 2
    Have you considered Javascript? see here stackoverflow.com/questions/4744105/… Commented Mar 2, 2012 at 17:41
  • 3
    If not your desire to stat with C# or something close I'd suggest IronRuby or IronPython Commented Mar 3, 2012 at 6:51

2 Answers 2


There are a few interpreted options that are more dynamic but close relatives of .NET. I think I would let my audience drive the choice.

  • For sys-admins I would try and expose powershell commandlets and let them use that. They should be comfortable over there, and it is a very powerful and .NET friendly tool. Credit to @jmh_gr for suggesting this in the comments.

  • For developers I would look at a dynamic CLR implementation of a well-known language. IronPython comes to mind. F# also has an interactive scripting mode that you might be able to use if you want to stick to more official-like languages.

  • For non-developers I would think about using something like Boo to create my own DSL so I could make the verbage make sense.

Finally, none of these strategies are mutually exclusive. In some ways, they build on one another as they require many of the same facilities to be successful.


You can reuse the machinery in Mono's C# Shell. It does what you've being doing with some improvements, like using a library containing a C# compiler, instead of running the command line one...


Adding automatic imports and referenced assemblies is quite easy, to make them available for your users.

It is dual licensed under the terms of the MIT X11 or GNU GPL

Code at https://github.com/mono/mono/tree/master/mcs/tools/csharp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.