8

The majority of material I have found regarding DLR is related to IronPython. Can you parse and execute C# using DLR? If so is there over head that would prevent you from attempting this on a web server with about 30 users?

More specifically I would like to script the configuration of my workflow objects when a user first initiates a workflow. Depending on conditions that change through out the year workflows may start at different steps, hence running configuration scripts seems like a good way to handle the variation.

David Robbins
  • 9,996
  • 7
  • 51
  • 82

3 Answers3

4

It sounds like you're really talking about the C# "compiler as a service" (at the end of this video), which will hopefully be in the 5.0 timescale for .NET (although Mono has it now). For now, CSharpCodeProvider is the best we have (which works largely like "csc").

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Thanks - was reading your blog today. Good stuff. Basically I debating whether I go the CSScript.net route or pursue the CSharpCodeProvider way. – David Robbins Jun 19 '09 at 20:55
  • Marc, can you recommend some good samples beyond the MSDN link? Thanks again. – David Robbins Jun 19 '09 at 20:56
  • Which - compiler as a service? Kinda hard, since it doesn't exist and won't for another year or so (at a guess). Or did I misunderstand the question...? – Marc Gravell Jun 19 '09 at 21:00
  • 2
    I don't know of any *specific* ones - but it isn't hard an IMO the MSDN example shows a lot of it. The main trick is remembering to includ C# 3.0: var compiler = new CSharpCodeProvider(new Dictionary() { { "CompilerVersion", "v3.5" } }); – Marc Gravell Jun 19 '09 at 21:08
0

Although Marc offered an alternative for me, I read this related SO question and C# and VB are not supported as of yet.

Community
  • 1
  • 1
David Robbins
  • 9,996
  • 7
  • 51
  • 82
0

You may find this relevant...though it doesn't run on the DLR itself.

Mono Compiler as a Service (MCS)

It has the advantage of running snippets and not loading a new assembly on every compile like CodeDom does.

Community
  • 1
  • 1
Jeff
  • 35,755
  • 15
  • 108
  • 220