Sharing CLSA Business Objects between different project types

Sharing CLSA Business Objects between different project types

Old forum URL:

jwheeler posted on Friday, June 24, 2011

Not sure this has been asked before but is it possible and are there any guidelines for sharing busness object code between different project types (i.e. WinForms, WPF, Silverlight, etc).  I am working on a WinForms application and eventually will be creating a companion Silverlight or ASP.NET application and would like to reuse/share as much code as possible.  (I know probably starting with WPF then move to Silverligh would be a better option, but currently converting an existing app for quick turnaround.) 

  1. Would partial classes be the way to go, seperating project type specific code in seperate files (i.e. Customer.Common.vb, Customer.WF.vb, Customer.WPF.vb, etc) and include the appropriate files in each project?
  2. What about using conditional compilation statements to group different implementations? Would this work?


RockfordLhotka replied on Friday, June 24, 2011

fwiw, I discuss this at some length in the Using CSLA 4 ebook series, and all the sample code is written to demonstrate how the same code can be used to build business assemblies for .NET, Silverlight, and Windows Phone.

You can also look at the SimpleNTier sample app in the Samples\Net\cs folder, because it has web, Windows, Silverlight and WP7 front ends.

Copyright (c) Marimer LLC