views:

171

answers:

4

Hi, I Have a library which has custom domain logic. Some of the stuff is heavy hitting and depend on the core runtime outside silverlight runtime.

Is it possible to compile the same code for 2 different runtimes and reference different flavours from different consumers? How

A: 

Add two class library projects (SLLib, CLRLib) to your solution. Then add all your .cs files to both solutions.

Nate Bross
Add files as link?
DotDot
+2  A: 

There are several ways to achieve what you want.

  1. You cannot reference full .net framework assemblies in silverlight, but you can do it the other way round, so you can code against SL and then reference SL projects in projects compiled against full .Net.

  2. You can add files from other projects as links to share source code instead of referencing assemblies

  3. Even better, you can use Prism v2 and Project Linker addin that comes with it to let Visual Studio manage files linking between projects. You can read more about multi-platform targeting here

jarek
Dude, it's not cool to put your website and linkedin reference on every single post.
mattmanser
+1  A: 

A simple, high level answer is that you put your common code in an assembly that both CLR and Silverlight assemblies reference. Anything that is specific to either platform must be abstracted out of the common code and implemented in the CLR and Silverlight projects.

Behold the wonders of inheritance and polymorphism ;)

[On a side note: if you find yourself copy-pasting code (either snippets or whole cs files), you're doing something very wrong]

AndrewS
A: 

Have you considered using Workflow Foundation for your task?

P.S. The question is VERY broad. Could you supply a sample so we have something to work with?

GregC
how will WF help us?
DotDot
I am sorry. Bad answer on my part.
GregC