简体   繁体   English

在C#Com包装器中使用Native dll并在silverlight中使用dll

[英]Using Native dlls in C# Com wrapper and Use dll in silverlight

As part of my project I need to use some Unamanged code dlls in Silverlight. 作为我项目的一部分,我需要在Silverlight中使用一些Unamanged代码dll。 If I wrap these unmanaged dlls in a C# dll will I be able to access the native dlls from silverlight. 如果我将这些非托管dll包装在C#dll中,我将能够从silverlight访问本机dll。 I use Visual Studio 2010 and Silverlight 4.0 我使用Visual Studio 2010和Silverlight 4.0

With Silverlight 4, you can call out to COM objects installed on the local machine. 使用Silverlight 4,您可以调用本地计算机上安装的COM对象。 However to do this the user has to choose to allow the Silverlight App full access to their machine. 但是,要执行此操作,用户必须选择允许Silverlight应用程序完全访问其计算机。

In addition the COM object needs to already be installed on the machine. 此外,COM对象需要已安装在计算机上。 Therefore the user would first have to separately download and install your DLLs before using any features that relied on them in your Silverlight application. 因此,在使用Silverlight应用程序中依赖它们的任何功能之前,用户首先必须单独下载并安装DLL。

Silverlight runs in the browser sandbox so it wont allow you to call directly to unmanaged assembly. Silverlight在浏览器沙箱中运行,因此它不允许您直接调用非托管程序集。 Eventhough you wrap the unmanaged code in a C# assembly, it still get loaded within the same app domain that is restricted by the same security restriction. 虽然您将非托管代码包装在C#程序集中,但仍然会在受同一安全限制限制的同一应用程序域中加载。

I have read that you can use html interoperability between silverlight and ActiveX, but I haven't experienced it myself. 我已经读过你可以使用silverlight和ActiveX之间的html互操作性,但我自己没有经历过。 Alternatively, you can deploy the complete WPF application and if you sign it with appropriate certificate and security setting, it can access unmanaged code - if this is an option. 或者,您可以部署完整的WPF应用程序,如果使用适当的证书和安全设置对其进行签名,则可以访问非托管代码 - 如果这是一个选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM