Somewhat OT: SL4, .NET 4, and sharing code

Somewhat OT: SL4, .NET 4, and sharing code

Old forum URL:

tmg4340 posted on Sunday, July 04, 2010

We're getting ready to start a Silverlight project at work.  Originally, we were going to do it in .NET 3.5 and SL3, but the project timeline may let that change to .NET 4 and SL4.

(I probably can't get them to use CSLA, but we'll see...)

Anyway, I hadn't been doing a lot of research on SL4 and .NET 4, largely because I didn't expect to have it available for my job for a while.  But now that I have, I keep coming across this "shared code" comment, and I'd like some clarification.

I've read Rocky's blog posts (and watched the Tech Ed session he did) about sharing code across SL and .NET projects.  But that was all predicated on the fact that .NET 3.5 & SL3 had different runtimes, and because of the wide disparity between what .NET can do and what SL3 can do.  But now I see that you can "share DLL's" between the two.  So does this alter the code-sharing philosophy that Rocky outlined - i.e. can we have one business-library DLL now?  Or is this strictly a WPF and Silverlight situation?

My initial thought is that it might be possible, but since there are still some wide disparities between what SL4 and full .NET supports, a client- and server-side library DLL would still be required.  But I'd like some more definitive information if I can get it, and the folks here are some of the smarter ones I've found, so...


- Scott

JonnyBee replied on Monday, July 05, 2010

Hi Scott,

Yes there is a possibility to "share DLLs" but not really an option for CSLA yet.

SL4 -> NET 4
For testing purposes- you may inject .NET 4 data access classes into a SL4 assembly using an IoC container. But not somtehing you would use in production and SL4 is available on more platforms than .NET4.

.NET4 -> SL4
.NET4 may load and use a SL4 assembly. CSLA core assembly _may_  evolve into a SL4 assembly so that we will not need to have 2 versions of CSLA (one for .NET4 and one for SL4). But as for CSLA 4 there is 2 versions of CSLA.dll, one for each runtime.

.NET4 actually has 2 runtime versions: Client Profile (CP) and Full. and .NET4 CP will most likely be rolled out on Windows Update for Vista and Win7 users. So we had potentially the same problem of one CSLA asembly for each runtime for .NET clients. In the development process we restructured the code and changed so that CSLA.dll has rutime target to .NET4 Client Profile to enable us to share asseblies between .NET4 client and servers. Code that requires .NET4 Full has been moved to sateelite assemblies like Csla.Web.dll and Csla.Web.Mvc.dll

And in the client - server perspective you MUST have 2 assemblies of you business objects - one business assembly that is downloaded and used on the client running SL4 and one server version running in .NET4 and having data access.

Copyright (c) Marimer LLC