DLR-based Silverlight component?

Nov 23, 2009 at 7:58 PM

I'm using:

v0.92 sources

VS.NET 2010 beta2

Silverlight 4

 

I'm trying to take an existing DLR-based component, compile it against SL4, and use it in an SL4 app, like this...

var dlrComponent = new DlrComponent( "some initialization goo" );

var result = dlrComponent.Execute( obj1, obj2 ); // this is where DLR kicks in, executes code dynamically, produces some result...

this.textBlock1.Text = result.ToString();

The project that contains DlrComponent references Microsoft.Dynamic and Microsoft.Scripting, built from 0.92 sources for SL4 (release). It compiles fine. At runtime, I get MemberAccessException for the first CallSite invoking a delegate.

I (sort of) understand SL security... DynamicMethod.Invoke is SecuritySafeCritical, so SL is clearly not happy invoking that method. But it's not clear to me why. Apparently there's some additional knob to twist to make SL security policy happy with my code as ultimate caller into DLR? Or perhaps there's no easy way to do that?

I've looked at MS.Scripting.Silverlight, but I didn't see anything particularly special about it from a privileged operation standpoint... and anyway, it's not really my usage model, since I'm not hosting a language in an HTML script so much as invoking a DLR-based component from a code-behind.

So, question... how do I go from CodePlex DLR source --> SL-based custom DLR component --> usage in an SL application?

 

Confused, but very hopeful... thanks in advance for any help!

Josh

 

Jan 4, 2010 at 11:38 PM

Josh, so you built Microsoft.Dynamic and Microsoft.Scripting against the SL4 binaries? I didn't think SL4 builds were working in the DLR Codeplex repo yet. Anyway, I have the DLR building and working fine in SL4 on my machine, so keep an eye out on the source repo for updates to project files enabling SL4 builds.

Jan 8, 2010 at 7:14 PM

Yep, it was working in SL4 (beta 2, anyway) back in November.

 

On an unrelated note, I figured out that my original problem prompting this thread was pure pilot error on my part... I was attempting to compile non-public members into an ET.

 

Josh

 

Jan 8, 2010 at 9:26 PM

> On an unrelated note, I figured out that my original problem prompting this thread was pure pilot error on my part... I was attempting to compile non-public members into an ET.

Hmm, non-public member access should work in SL 4, assuming it’s using the DLR support in System.Core and not Microsoft.Scripting.Core. But maybe the Silverlight package hasn’t been updated yet to take advantage of the built in DLR support? Jimmy would know for sure.

- John

Jan 12, 2010 at 5:38 AM
> But maybe the Silverlight package hasn’t been updated yet to take
> advantage of the built in DLR support? Jimmy would know for sure.

Yeah, no Silverlight build yet for SL4 (that works at least =P).