Marshalling unmanaged code in silverlight

China☆狼群 提交于 2019-12-12 04:58:26

问题


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.



来源:https://stackoverflow.com/questions/1234395/marshalling-unmanaged-code-in-silverlight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!