Question

I have a solution that contains both a Silverlight 4 and a WPF 4 solution. One is the web version of the app and one is the desktop version.

Both projects have similar domain classes and interfaces and both access the cloud for storage and other stuff.

I wanted to create a common Interfaces and Classes project, so I created a Class Library, but wouldnt you know it, Silverlight cannot add a reference to a Class Library. So I created the common project as a Silverlight Class Library, but when I reference that from the WPF project I get warnings:

Warning The project 'Interface.Common.Silverlight' cannot be referenced. The referenced project is targeted to a different framework family (Silverlight)

and I even get class loading runtime errors when I use any class from that library because "System.Windows cannot be found at runtime"

I want to share code between the two projects, how can this be achieved in a clean way?

Thanks for any help you can give

Was it helpful?

Solution

Create two parallel projects one for WPF and one for Silverligth. For one of the projects, add the files as links instead of files.

I have done this sucessfully for the Microsoft Silverlight Analytics Framework with one code base for Silverlight 4, WPF, and Windows Phone 7.

OTHER TIPS

What about xaml sharing code with silverlight and WPF

Create a "Portable" project. that can be referenced from both WPF and Silverlight

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top