views:

674

answers:

1

Hello all,

I've got this small web application I've built. It's got an activex control returning unmanaged code through javascript into a silverlight application. In silverlight I perform a marshaling operation on the returned value. When I only perform the simple operation of GetSize() I get struck with a stupefing error. This brings me to my question: Is it possible to perform a marhsalling operation in silverlight, if so how?

+3  A: 

Silverlight's security model and sandbox do not allow "transparent" (user code and applications) to perform p/invokes, trusted operations, or anything of that sort.

If you already have an ActiveX control installed and available to the web page, you'll need to use the HTML Interoperability features of Silverlight to marshall the data yourself. There's an MSDN article about the HTML bridge that's specific to Silverlight 2, but you'll find it the same in newer releases of Silverlight as well.

This assumes that your ActiveX control is accessible through browsing scripting / JavaScript already.

Though some marshalling of numbers and some other primitives works well in the platform, you'll likely end up moving all your data from your ActiveX control through the use of strings, then parsing it back on the Silverlight client.

This might at least enable your scenario.

Jeff Wilcox
I am trying to pass an array of bytes from activex through javascript and into silverlight. Since javascript only supports native unmanaged code I cannot send my array of bytes. Therefore I thought of performing a simple marshaling orpeation, which too fails... Is there any way to bypass this?
vondip
You may be able to encode that array of bytes. In JavaScript, can you walk through the array of bytes and convert each into a hexidecimal string? You can then pass that to Silverlight. The HTML interoperability feature is the way to get this done, but you're going to have to do some work inbetween.
Jeff Wilcox
wow, I have a huge byte array (I mean, really big something similar to encoding an image) is that the only way to go?
vondip
I don't think so :-( the performance will probably be a big problem. Perhaps you could post another question (or clarify this one) to be more specific to your actual scenario -- perhaps there's a better way to go about this all.
Jeff Wilcox