RIA Services shared code instead of project linker

Topics: Prism v2 - Silverlight 3, Prism v2 - Silverlight 4, Prism v2 - WPF 3.5, Prism v2 - WPF 4
Jun 2, 2010 at 3:25 AM
Edited Jun 2, 2010 at 3:25 AM


As I see you are still upgrading project linker. But what about shared code feature of RIA services. Isn't it a better approach?

Best regards,

Alexey Zakharov

Jun 4, 2010 at 9:07 PM

Hi Alexey,

The main difference between these technologies is that they target different scenarios. The shared feature of RIA Services is useful for sharing code between the middle tier and the presentation tier of an application, as exemplified on this blog post. However, the scenario in Prism is different, as the sharing of code in Prism usually needs to be done between a similar solutions that target different technologies (WPF and Silverlight). You would probably choose the one that suits better to you depending on your requirements. Below you can find my thoughts on why Project Linker probably suits better the multi-targeting scenario.

From the MSDN documentation, shared code offers two possibilities for sharing source:

  1. The first possibility is using the shared naming convention, which has the disadvantages that the developer must be aware of that convention, and that the files are physically copied between the projects.
  2. The second possibility is using linked files, which is an out-of-the-box capability of Visual Studio. The problems with this approach are mainly that the developer must link each file, and there is no self-maintenance.

The Project Linker addresses the problems of both approaches, as it:

  • Implies knowledge of no conventions whatsoever.
  • Does not physically copy the files.
  • Links entire projects, avoids the need of linking each file separately.
  • Keeps the target project updated when files are added or removed in the source project.

Another point of interest is that, if you use the first approach mentioned in shared code, as source files are copied into the target project in compile time, you might end up in a situation in which you modify the copied file and when you compile the solution, it gets overridden and the changes are lost. This behavior might confuse developers.

I hope you find this helpful.

Guido Leandro Maliandi

Jun 6, 2010 at 6:37 PM

Thank you for this feedback. It is very useful.

Because we are using Prism with Silverlight only shared code suits us better.