Skip to content

Instantly share code, notes, and snippets.

@PollRobots
Created February 1, 2013 08:40
Show Gist options
  • Save PollRobots/4690135 to your computer and use it in GitHub Desktop.
Save PollRobots/4690135 to your computer and use it in GitHub Desktop.
use compiler = new FSharpCodeProvider()
let parameters = CompilerParameters()
parameters.GenerateExecutable <- true
parameters.GenerateInMemory <- true
let result = compiler.CompileAssemblyFromSource(parameters, parser)
if result.Errors.Count > 0 then
for error in result.Errors do eprintfn "%O" error done
else
for output in result.Output do printfn "%O" output done
printfn "Executing..."
try
result.CompiledAssembly.EntryPoint.Invoke(null, null) |> ignore
with
| ex -> eprintfn "Error executing generated code: %s" ex.Message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment