user1256275
user1256275

Reputation: 91

Cross compiling silver light class library to a .net class library using conditional compilation

I have a silverlight class library containing business entities, i want these entities to be reused in one of my .net class library. I am not able to use Portable class library because, my silverlight class library has the references to some of the silverlight's core component dlls which are not supported by the Portable library tool. I have introduced conditional compilation, so that the code specific to the silverlight builds only if the compiler is targeting silverlight. My question is using Visual studio, how can i generate the .net 4.0 runtime assembly for the same silverlight class library? Any help would be appreciated..

Alpee

Upvotes: 1

Views: 106

Answers (2)

Adriaan Davel
Adriaan Davel

Reputation: 748

Are you sure you won't be passing those business entities through a service at some stage? If so, create business entities on the server side and the service reference will re-create them in Silverlight. You could then use partial classes to split data definition and class logic and add the class logic file back to Silverlight (using compiler directives for namespaces). We do this all the time, works well.

Upvotes: 0

Anders Gustafsson
Anders Gustafsson

Reputation: 15981

Microsoft provides the Project Linker tool for scenarios when you need to build for example Silverlight and .NET Framework libraries from the same code base. You can download the tool from here.

Initially, you will need to create a separate .NET project and add as links the files from the Silverlight library.

After installing Project Linker, you can then link the Silverlight project as being the source of the .NET project target. When you now make changes to the Silverlight project, including file and folder additions and deletions, these changes will be automatically reflected in the .NET project.

Upvotes: 3

Related Questions