Amil
Amil

Reputation: 503

Calling c++ clr dll in c# silverlight

We have a c++ clr application that we have compiled into a dll. We exposed several methods through a managed public ref class in the c++ code. We were actually able to have our native c# application load this dll and pass a system::drawing::bitmap by reference. All we needed to do was add a reference to the dll and all methods were exposed due to implicit pinvoke. However, as soon as we try to load the dll in our silverlight application, things blow up. Apparently the c++ clr .net libraries used are not compatible with those of silverlight. We have tried many things, but just can't get silverlight to call our dll.

Please, does anybody have any suggestions on how to resolve this? Anything would be apprciated!

Thank you!

Upvotes: 1

Views: 1250

Answers (1)

shf301
shf301

Reputation: 31394

You have three main options I can think of:

  1. Rewrite the logic in the C++/CLR DLL in a Silverlight DLL. As of Silverlight 5 you can use P/Invoke.
  2. Create a web service that calls your C++/CLR DLL. The Silverlight app can call a web service and the web service will be able to use the C++/CLR DLL.
  3. Expose your C++/CLR DLL as a COM object, install and register it on the Client computer, and use the COM support in Silverlight to load the C++/CLR DLL.

Upvotes: 2

Related Questions