As I mentioned in my very first blog post, I intend on writing a series of posts about using Silverlight with Prism – something similar to The Application Corner with Tim Heuer. In order to get a jump start on the series, I thought it’d be a good idea to get the “setup” post done and out of the way. So without further ado…

Prerequisites

In order to follow along with this post and series, I assume the following:

  • You’re familiar with the Prism guidance concepts and understand why you would use it to build a Silverlight application. If you’re not familiar with Prism and it’s concepts, stop right now and read the documentation on MSDN. I’ll wait for you, I promise. :)
  • You’re an experienced C#/VB software developer.
  • You have some exposure (or a strong interest in learning) software design patterns such as Inversion of Control (IoC), Dependency Injection (DI), Model-View-Presenter (MVP), Model-View-ViewModel (MVVM).
  • You have Visual Studio 2008 SP1 installed on your system.
  • You have Silverlight Tools for Visual Studio 2008 SP1 installed on your system.
  • You have some exposure working with Silverlight 2 (doesn’t need to be much – as long as you’re familiar with the structure of a Silverlight 2 project, XAML, and code behind).

Ok, now that I have the obligatory prereqs out of the way, let’s get started.

Setting up our Silverlight/Prism Solution

  1. For starters we need to install Prism on our local machine – which is relatively trivial:
    1. Download prism from this page. NOTE: You may also want to download the documentation - I prefer to use the online docs at: msdn.microsoft.com.
    2. Run the self extracting file and extract the files to a folder named Prism V2
    3. Move the Prism V2 folder extracted the files to C:\Program Files\Microsoft SDKs\ (or C:\Program Files (x86)\Microsoft SDKs\ if you’re running a 64-bit OS).
      NOTE: You don’t have to move the Prism V2 folder to the Microsoft SDKs folder, I just like to keep all my SDK stuff located in the a common place and the Microsoft SDKs folder makes sense.
  2. Alright, now fire up VS2008 and create a blank Visual Studio Solution named Prism.Framework.
    NOTE: The names you choose for your solutions and projects are arbitrary - it’ll just make things easier for you to use the names I do, especially if you’ll be following along with this blog series.

     image
  3. In the Solution Explorer, right-click on the Prism.Framework solution and click Add –> New Project… –> Visual C# –> Web –> WCF Service Application. Use Prism.Framework.Api as the project name. Click OK.

    image 
  4. In the Solution Explorer, right-click on the Prism.Framework solution and click Add –> New Project… –> Visual C# –> Silverlight –> Silverlight Application. Use Prism.Framework.Shell as the project name. Click OK.

    image
  5. In the Add Silverlight Application dialog window that pops up after step 4, choose Add a new ASP.NET Web project to the solution to host Silverlight, Project Type: ASP.NET Web Application Project, and use Prism.Framework.Web as the name.

    image

And that’s it! Let’s look at what we just did:

  1. Created a Prism.Framework solution to house all the projects related to this blog series.
  2. Created the Prism.Framework.Api WCF project which will serve as the means of communicating with backend systems. This will be deployed to the web server as: http://api.yourdomain.com.
  3. Created the Prism.Framework.Web.Shell project. This project will serve as the application shell into which we’ll load our application’s various modules.
  4. Created the Prism.Framework.Web project to host the Silverlight shell. This will eventually be deployed to the web server as: http://www.yourdomain.com.

Now you might be asking yourself, why can’t we just use the Prism.Framework.Web project to host both the Silverlight shell and WCF services projects? We could certainly do that, but by putting the WCF services in their own project, we decouple those services from the web site hosting the Silverlight shell, therefore making them logically available to other applications. Plus, now we have a reason to implement a Silverlight clientaccesspolicy.xml file in a future post. :)

In the next post we’ll configure the Prism.Framework.Web.Shell project to use the Prism framework.