views:

461

answers:

2

As part of my project I need to use some Unamanged code dlls in Silverlight. If I wrap these unmanaged dlls in a C# dll will I be able to access the native dlls from silverlight. I use Visual Studio 2010 and Silverlight 4.0

A: 

Silverlight runs in the browser sandbox so it wont allow you to call directly to unmanaged assembly. 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.

I have read that you can use html interoperability between silverlight and ActiveX, but I haven't experienced it myself. 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.

Fadrian Sudaman
+5  A: 

With Silverlight 4, you can call out to COM objects installed on the local machine. However to do this the user has to choose to allow the Silverlight App full access to their machine.

In addition the COM object needs to already be installed on the machine. 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.

David
+1, it should also be noted that not only does the app need full trust, but it also needs to be running Out of Browser.
Steve Danner