Compile LambdaExpressions into Silverlight-compatible DLLs?

Sep 15, 2009 at 6:23 AM
Hi All-

A while ago, I successfully built a DLR based language.  On the server side, it did what I needed it to do.  But now I'm hoping to extend it to use in silverlight.

While I know I could send source to a silverlight app and it could compile it for itself just fine, I'd like to find a way to avoid that step:  I'd really like to find a way to cross compile the source to my language(XtraDLRge) to a silverlight compatible dll on the server side, then cache it, then send that pre compiled dll to the requesting silverlight user on demand.

1)  Is there any way to achieve this with the DLR right now?
2)  If not, is this on the DLR team's radar?  I'd imagine this would get increasingly necessary with Silverlight for Mobile.

Thanks for your thoughts
Mike Kohout
Sep 15, 2009 at 7:51 AM
Edited Sep 15, 2009 at 7:52 AM

1. Your DLR-based language is able to produce pre-compiled DLLs against the full .NET framework
2. You can compile from source in Silverlight on the client (as IronPython and IronRuby do)

... then nothing is stopping you from pre-compiling against the Silverlight binaries. Instead of using the full .NET framework's version of mscorlib.dll, System.dll, etc, use Silverlight's version (all of Silverlight's assemblies exist in "c:\program files\microsoft silverlight\3.0.40723.0"). If you put Silverlight's assemblies on your server, then you could generate a Silverlight-compatible DLL from your language, and send it to the client as need be.

Is that your question? Have you already tried this and are running into issues?

Sep 15, 2009 at 4:21 PM

I think the questions is rather how could a full-framework app generate an assembly via Reflection.Emit that references Silverlight assemblies only. I'm affraid it's not straightforward to do so. One way how to achieve it is to generate an assembly that references the full framework assemblies and then IL-rewrite the assembly references to corresponding Silverlight ones. You can e.g. use ildasm and ilasm or CCI to do the rewriting.