Note: This is part of a series…. Well, it will be
You can find the related posts here…
Alright, let’s start looking into some Silverlight 3 (SL3) development. Specifically of business applications.
First step is a respective solution. I created a new “Silverlight Navigation Application”, with SL hosted in a web site, and got the typical solution structure. Needless to say, that this structure doesn’t meet my requirements.
First, I’m going to have a bunch more assemblies. And since SL assemblies are different from “ordinary” assemblies – they work against a different runtime and use different libraries – I like to have them clearly distinguishable. I did this a) with respective solution folders and b) with an added namespace part “SL3”.
The Server Part
On the server side I added two assemblies:
One data access assembly. This contains the ADO.NET Entity Framework access to the database. For the purpose of this application, this constitutes the business layer. (A little simplistic, but bear with me, the focus is on the client.)
A “Common” assembly. There will be server side parts of logic that may be reused in other applications.
I also made some adjustments to the web application (project properties/web): I changed virtual path to “/xBookshelf”, I don’t like my web apps to occupy the root. And I set the port to “specific port”. It doesn’t matter which one, it’s just a little annoying to have to update service references when the port is changed by VS every now and then. Speaking of services, I’m going to put them in a separate folder.
The Client Part
My naming convention for SL3 assemblies is Company.Application.SL3… . Specifically I renamed the SL assembly containing the XAML files to SDX.Bookshelf.SL3.UI. Renaming the .xap file affects the web project and the hosting pages. I also changed the pages to have Page as postfix.
And there are a few additional assemblies as well:
SDX.Bookshelf.SL3.Model contains the view models, as I’m going to use the Model-View-ViewModel pattern.
SDX.Bookshelf.SL3.Service contains all service references. Since this is all generated code, I thought it prudent to cleanly separate it.
SDX.SL3.Common is the counterpart to the server side common assembly. It will contain everything that may be reused in other application.
Setting the project dependencies and getting it all to run again is just a bit tedious, especially because the startup project is the web project, but the application in question is the UI project.
The final test for the reworked solution is opening it in Blend – which may be not as trivial as it sounds
You will at least get one warning dialog telling you that blend does not support solution folders. Never mind, that’s of no consequence.
In one project I also run into a serious issue: Blend refused to open the solution with the following dialog:
Also subsequently I got a large message box with an exception stack trace.
To work around this problem, I removed all projects from the solution and added them again in Blend. I was able to provoke that bug by reordering the sequence of the projects within the .sln file, hence it’s probably due to some project dependencies that blend can’t solve correctly.
Anyway, don’t let that bias your perception. Blend may be awkward, and it takes time getting used to – but is worth the effort.
That’s all for now,