Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you compile code on the fly in Silverlight?

I should clarify that I am looking for a client-side solution.

Alternatively, is there a C# compiler written in managed code?

like image 914
MMind Avatar asked Nov 16 '08 05:11

MMind


1 Answers

On the Client

Take a look at the Dynamic Language Runtime if you're using Silverlight 2.0:

  • http://www.silverlightexamples.net/post/Execute-Code-String-at-Runtime-with-Silverlight-20-DLR.aspx
  • http://silverlight.net/learn/dynamiclanguages.aspx

Server or Client with Full Trust

This example uses the Microsoft.CSharp.CSharpCodeProvider, compiles on the server, and sends the assembly down to the client:

  • http://www.cnblogs.com/baggiojing/archive/2008/11/03/1325297.html

There's a VB equivalent. They allow you to compile to disk or in memory. In most cases you can't use them on the client because they require full trust.

Other examples:

  • http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2007/12/20/how-to-compile-c-3-0-code-dynamically.aspx
  • http://www.developerfusion.com/article/4529/using-net-to-make-your-application-scriptable/3/

Silverlight with full trust:

  • http://blogs.microsoft.co.il/blogs/tamir/archive/2008/04/27/how-to-make-silverlight-be-air.aspx
  • http://www.silverlightshow.net/items/Silverlight-Running-standalone-full-trust-applications.aspx
like image 104
Corbin March Avatar answered Oct 04 '22 19:10

Corbin March