简体   繁体   中英

Compile F# code in browser (Silverlight)

I want to create a Web page that compiles F# code and executes it in the context of this Web page, maybe with some kind of JavaScript interop. Like tryfsharp.org does. In can be, however, server-side compilation, but the assembly should be executed in the browser context (Silverlight probably?).

The problem is that I do not know really what to do at the beginning. I've tried to google for it and the best suggestion I have now is to look at http://fsharppowerpack.codeplex.com/ . Is it correct? Should I try to run F# code DOM in silverlight or something? It should not be REPL, ideally it is just a textarea with code file.

There are two main options, depending on where the compilation happens. Running it on the server will probably be easier, but I think both should be doable.

  • For compiling F# on the server, the best option is to use the SimpleCompilerService API from F# Compiler Service . This invokes the compiler with whatever options you need, so it should let you compile Silverlight assemblies (but you'll probably need Silverlight SDK on the server).

  • For compiling F# in a web browser, you'll need a Silverlight build of the compiler services. I have not used this recently, but look at the F# open source repo , which has a note on this (search for "You can also build the FSharp.Core and FSharp.Compiler.Silverlight.dll for Silverlight 5.0" in the README)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM