I am new to Silverlight. We are migrating our project to Silverlight. We are just changing our presentation layer. (ASP.NET WebForms site to Silverlight web application). So our other class libraries having business & data access layer will remain as it is.
Firstly I added a Silverlight web application to my solution. It created 2 projects: PM_Tool and Pm_Tool.Web. Now I need to add project references of the Business and Data Access layers to this, since I need to access them in my MainPage.xaml.cs.
But I can’t add a reference to Pm_Tool – I get the following message:
You can only add project reference to other Silverlight projects in the solution.
I then added project references to Pm_Tool.Web, but I can’t access the business layer objects in MainPage.
Can anyone help how I can proceed further?
A Silverlight application can only reference other Silverlight projects. This is simply because Silverlight uses a lighter version of the .NET framework; if you could reference ‘full’ .NET projects then it would be required to support the entire framework. Microsoft have made a design decision to limit the functionality – presumably this is to reduce the installation & runtime footprint of Silverlight.
Having said that, it’s quite likely that most of your code will still run in Silverlight. You should create “Silverlight Class Library” projects and include your classes into those projects. You will soon see which (if any) classes are using parts of the framework that are not supported by Silverlight. From there, implement workarounds.
Of course all your data access and server side code must remain in your ‘Web’ project. Silverlight implements a correct client-server model and doesn’t allow you to ‘cross the boundary’ in the same way that ASP.NET WebForms does. Your Silverlight application runs solely in the browser – anything that needs to happen ‘on the server’ must happen in the ‘Web’ project. Your Silverlight application posts and gets information from the ‘Web’ project via WCF (or
WebClient, etc).Unless you have a very well designed ASP.NET solution, I would expect that your transition is not going to be as simple as ‘just changing our presentation layer’.