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?
问题:
回答1:
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.