views:

114

answers:

2

Are there any aggregated guides to writing libraries which need to be Silverlight-compatible?

Or is the standard procedure to just build, look for errors, fix, repeat?

Obviously I recognize the answer may depend on what version of Silverlight is being targeted, but I'd expect any answer to just specify version if the solution is specific.


Clarification: Basically I want the library to work for both plain-old CLR and Silverlight and not reference any Silverlight specific libs. If it needs to reference such libs in order for it to work in Silverlight, then I'd prefer use conditional compilation and produce a specialized build. Ideally it would just work as I could pick a subset of functionality of the two.


Are there any definitive resources for this? I'm mostly looking for a website which lists common things to watch out for. Basically proactive rather than just looking for issues after an approach is taken.

+4  A: 

Do you mean to share code between a Silverlight project and a regular CLR project? In that case I usually write the code as a Silverlight project to make sure I don't use any features not available there. As long as you stay away from the Gui components your code will be compatible with .Net as well.

It is possible to reference Silverlight 4 assemblies from the .Net 4 runtime. Here you have the same situation, but you only need to compile one version of your assembly.

Rune Grimstad
A: 

Starting a community wiki for links to resources on this topic. (Still searching for a list of API delta between standard CLRs and Silverlight CLRs.)

Targeting multiple CLRs with the same code:

Silverlight fully runs on a different version of the CLR which is binary incompatible with the standard CLR. So you literally cannot build a library which targets both. However, you can use the exact same code files for both built targeting each environment.

(Alternatively you can do the same thing a single .csproj if you are careful with your conditional attributes.)

Differences Between WPF and Silverlight 2.0:

Differences Between WPF and Silverlight 1.1:

Silverlight Differences on Windows and Macintosh:

Differences in Silverlight on Windows Phone:

Yet another variation is the Windows Phone implementation of Silverlight.

McKAMEY