开发者

Cannot add reference to DLL assembly in Silverlight 5 application

I'm trying to use the Dynamic Data Display (D3) library for display开发者_JAVA技巧ing graphs in a Silverlight 5 application (out-of-browser). Whenever I try to add "DynamicDataDisplay.dll" as reference, it gets removed again after I close the dialog.

I can however use the reference in a normal Windows Forms or WPF project. So is this some restriction with the Silverlight framework?

What can I do about this? Maybe compile D3 myself in a different way?


Silverlight applications can only use assemblies compiled by Silverlight projects. There are exceptions but for anything UI related it's always true.

As a result, if you want to use a third-party library in your Silverlight application, it needs to have a special Silverlight version to use instead of the normal version. The "normal" version is sometimes called the .NET4 version or the WPF version to contrast it with the Silverlight version.

The net effect is that Silverlight is for all practical purposes not binary compatible with the full CLR. But there is a considerable amount of source compatibility including large sections of the core framework and a partially incompatible subset of WPF.

In fact the standard approach to building parallel WPF and Silverlight assemblies is to use two projects that link all the same source files with some conditional compilation.

Luckily for you, as @dtb pointed out, Dynamic Data Display already supports a Silverlight download. But the same applies to any third-party library you might consider using: it needs to come in a Silverlight flavor.


If the D3 dll depends on the full install of .Net and not just the silverlight subset, Silverlight will not allow a direct import. You would have to host the .dll on your server and expose asynchronous service methods to it. Unless this is a really killer DLL, it is not worth it...


You can also use portable class libraries as well I'm silverlight

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜