.netsilverlight

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?


Solution

  • On the Client

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


    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:

    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:

    Silverlight with full trust: