Latest Tweet:
  • Loading...

The background for this article is a discussion thread on the Regional Director discussions list. One of my fellow RDs asked the question weather Silverlight 2 was ready for business applications or not. Based on my reply to the discussion Derek Hatchard asked me to turn it into an article he could publish on the "{You Shape} it" site. The article is now published, but since the {You Shape} it site doesn't support comments, and to make this article available to my subscribers who might not know of the site, I've decided to publish it on here as well. Microsoft Regional Director Rockford Lhotka has published a blog post with the same title as this article. I recommend reading it for his views on Silverlight for business applications. Rocky's post is written as a response to a Ivan Dragoev's post which suggest that the Silverlight 2 platform might not be ready for some serious business/data scenarios yet.

Introduction

With the initial release of Silverlight back in 2007 the focus was on building rich online media experiences with support for high definition video content in the browser. However, there were not many features addressing the needs of developers building data centric line of business applications. With the recent release of Silverlight 2 application developers are asking themselves if Silverlight is ready for business applications. Short answer: definitively yes! With Silverlight 2 you get the power of .NET in the browser, a rich control model, strong data binding support and a solid networking stack with support for WCF, ADO.NET Data Services and REST services. Essentially all the building blocks you need to start developing great Rich Internet Applications that solve business needs.

In this article I will try to highlight some of the strengths of Silverlight 2 as a platform for building data centric business applications, compared to traditional web applications. I will also try to address some of the challenges and concerns developers have around adopting Silverlight 2 today. Some of these concerns are around things like printing, search engine optimization, deep linking and bookmarking. All of these issues can be addressed using various techniques I will touch on in this article.

New Possibilities with Silverlight 2

I figured a good place to start would be by looking at some of the new scenarios enabled by Silverlight 2 that previously would have been impossible or really hard using regular web technologies such as HTML and JavaScript. For most developers, the greatest thing about Silverlight 2 is that you get .NET running in the browser on Windows and OS X (and Linux in the future). You can use your favorite programming language to build your application, supported by the productivity of Visual Studio 2008. You no longer have to use JavaScript to write code on the client (unless you want to). Tooling support for JavaScript was greatly improved in Visual Studio 2008 but still has a long way to go to match C# and VB.NET. Silverlight 2 supports C# and VB.NET out of the box, and you can also write Silverlight 2 applications using dynamic languages such as IronPython or IronRuby.

Having .NET in the browser lets you use the same skill set and programming languages on the client that you use on the server and provides a solid foundation for coding client side validation, business rules, and application logic.

Offline Storage of Data

Silverlight 2 supports offline storage through Isolated Storage, a protected area on the user's hard drive. Each application gets its own isolated space where it can read and write data. This can help application developers improve performance by serializing reference data to XML or JSON and stored it locally for later use. The next time the user loads the application startup time will be improved as reference data is read locally.

Another scenario where offline storage could improve user experience is by saving uncompleted forms. How many times have you accidently closed the browser before completing a web form or had to come back later to complete a form because you where missing some details? In those scenarios the application could save form values locally as the user types. If the user closes the browser and later comes back to complete the form, the application can read the form values from isolated storage.

Access to Local Files and Improved File Uploading

Security is a top priority in Silverlight 2 and there is no way you can read arbitrary files on the hard drive. However the user can choose to give Silverlight 2 access to a local file using the file open dialog. Unlike the standard HTML file input element, you can access the content of the file passed in locally. This can be used to create improved file uploaders that support multiple files at the same time with accurate progress indicators. Or you could use local file access to import and transform CSV or XML files locally before sending the data back to the server.

Multi Threading, Real-Time Networking, and Cross Domain Services

Silverlight 2 supports multi threaded programming, something currently not available in JavaScript. This allows for more complex work on the client without blocking the user interface. Examples of this could be financial calculators, complex validation logic, or other long running background tasks.

The Silverlight 2 networking stack allows real-time network communication over sockets. The client application can open a connection to the server, and the server can push data back to the client. This enables new scenarios, such as constantly up-to-date stock tickers and real-time monitoring of industrial processes or other physical equipment.

One of the limitations developers often run into when working with AJAX is calling web services from other domains than the one hosting the page. In Silverlight 2 cross domain networking is supported if the service explicitly allows this through a policy file. This enables you to call services such as Flickr, YouTube, and Amazon directly from the browser and even access web services hosted on other machines inside the enterprise.

Rich Control Framework for Great User Experiences

So far I have only covered non-visual aspects of Silverlight 2, and in fact all the features I have mentioned so far you could use in a traditional web application by hosting a non-visual Silverlight 2 application and integrate it using the HTML Bridge. But the place Silverlight 2 really shines is the presentation model. You get a control model similar to the one in WPF, and out of the box Silverlight 2 ships with the main controls you would expect like TextBox, Button, ListBox, ComboBox, DataGrid, Slider, DateTimePicker, and many more.

Having a strong set of controls is a key requirement in any data centric business application, and Microsoft has announced that they will continue to improve the Silverlight 2 control story by releasing additional controls as a Silverlight Toolkit hosted on CodePlex. The first batch of new controls will be made available at the PDC next week and will include controls such as TreeView, Expander, Label, Accordion, NumericUpDown, AutoComplete, and a couple more. This is just the first drop of controls and Scott Guthrie has hinted that they expect to ultimately have more than 100 controls available on CodePlex. If the controls from Microsoft do not meet your requirements there is already a large ecosystem of third party controls available.

All Silverlight 2 controls support data binding, making it easy to bind your user interface components against properties on your business objects. This greatly reduces the amount of code you have to write in the UI layer as you no longer have to write the repetitive code of moving values from your textboxes onto your business objects. By applying design patterns like Model-View-ViewModel you can build user interfaces with literally no code behind, making your application easier to unit test.

Strong data binding support combined with the power of .NET makes it easier to write complex validation rules on the client. This enables you to do more validation on the client side without having to do round-trips to the server to validate user input. This isn’t something new to Silverlight 2 and can be achieved using JavaScript. However, writing the validation rules in managed code is easier and more productive compared to JavaScript. In some cases you would also be able to reuse some of your business logic code between server and client. A framework like CSLA.NET can help you architect your application in such a way.

One of the strengths of the Silverlight 2 control model is the separation of visual representation and behavior. Using XAML you can redefine the look and feel of a control without losing its behavior. A slider control to set a visual indicator of air pressure in a tank can be restyled to look like a tank where you can drag content up and down. Checkboxes to set gender can be redesigned to use a male/female icon, but still keep the behavior of a checkbox. Similar things can be achieved using HTML and JavaScript, but Silverlight 2 makes scenarios like this real easy and the styling can be done by a designer without having to change the underlying code using the checkbox or slider control. The clean separation of XAML and interaction logic enables new designer-developer workflows previously hard to implement.

Visualizations and Animations

In addition to powerful controls, the Silverlight 2 presentation model has great support for vector graphics, multimedia, Deep Zoom imagery, and animations. Some might dismiss these features as something not suited for a business application. But who said a business application had to be boring? Using the vector drawing capabilities you can create graphics to visualize your business data in new ways. Already there are multiple charting and gauge controls available. Deep Zoom enables you to view gigapixel images over the Internet, opening up new possibilities for data visualization previously not possible. The Microsoft Health Common User Interface application demonstrates how a radiologist could examine and annotate x-ray imagery remotely using Deep Zoom and Silverlight 2.

Animations, when used appropriately, can greatly enhance the user experience of a traditional business application. Based on selections made by the user, animations can be applied to emphasize certain sections of the page, or to show or hide sections based on the selection. Billy Hollis recently did a DotNetRocksTV episode demonstrating a traditional business application where animations greatly help improve the user experience.

WPF Portability

Silverlight 2 uses a subset of the .NET runtime, and the presentation model is based on WPF. This allows for both code and skill reuse between platforms. Silverlight 2 is a web technology and there might be cases where you want a full desktop version of your application. Access to local resources, support for offline access, or integration with Microsoft Office could be reasons to use WPF. If you decide to make a WPF version of your Silverlight 2 application you will be able to reuse most of your business logic code directly. There are some differences in the XAML and control styling model between WPF and Silverlight 2 that you have to take into consideration when porting your user interface. Silverlight 2 uses a new Visual State Manager component to manage the look and feel of a control in different states. A checkbox, for instance, will have one look for the checked state and one look for the unchecked state. In WPF you manage different states using triggers, something currently not supported in Silverlight 2. Microsoft has announced that they will include the Visual State Model to the next version of WPF to align it with Silverlight 2. While waiting for the Visual State Model to be implemented in WPF you can use Microsoft Expression Studio architect John Gossman's implementation. This would help make portability of Silverlight 2 applications to WPF easier.

Since Silverlight 2 and WPF support the same vector graphics you will be able to reuse any graphic assets created in Expression Design or Adobe Illustrator. This is great for logos, icons, or any other illustration your designers would create for your project.

Arguably the most important piece of reusability between Silverlight 2 and WPF is skills / experience. The two platforms have so much in common that if you start out with Silverlight 2, the transition to WPF will be a lot easier. Silverlight 2 has a smaller feature set than WPF, making it a more approachable starting point.

If you want to learn more about WPF portability, I have a blog post describing the process of porting my Dive Log sample application from Silverlight 2 to WPF.

Deep Linking, Search Engine Optimization, and Printing

One question I get asked a lot is how search engines deal with Silverlight 2 content. From a business application point of view, this might not always be an issue as many applications will be hosted inside the enterprise behind password protected sites. However, there are scenarios where search engine optimization is important for Silverlight 2 business applications. One example could be an online product catalog created in Silverlight 2. I'm sure the marketing department would be rather concerned about the discoverability of their products using search engines. The two key things to think about for search engine optimization are indexability and relevance. Indexability is achieved by addressing what content is visible to the crawler and where the crawler should look. Relevance is achieved by providing deep linking to individual pieces of content so that people can link to your application.

In our product catalog example deep linking could be implemented by adding a parameter to the URL hosting the Silverlight 2 application indicating which product to load. When the Silverlight 2 application loads it could read the URL and load the correct product. This would enable users to share links directly to a specific product or add a bookmark. At the same time the web server rendering the initial page hosting the application could provide a HTML representation of the product page hidden underneath the Silverlight 2 control. The user would only see the Silverlight 2 representation of the product catalog, but the crawler could index the HTML content underneath. To help the crawler find all the products you could supply a sitemap file containing links to each individual product in the catalog. For more information on search engine optimization check out Nikhil Kothari's blog post on Search for Rich Internet Applications.

Printing in Silverlight 2

By default Internet Explorer 7 supports printing of Silverlight 2 content but other browsers such as Safari and Firefox currently don't. For our product catalog this would be a major issue. Rendering HTML content behind the Silverlight 2 control would not only improve indexability, it could also help us improve the printing experience. Using standard CSS print stylesheets, we could hide the Silverlight 2 container when printing the page and instead apply styles to show the HTML content sitting behind it. When the user browses the catalog and selects new products we could use the HTML Bridge in Silverlight 2 to dynamically upgrade the HTML content based on the currently selected product. This way the user always gets a nice looking printout in all browsers. I recently did a blog post describing this technique, as well as covering printing in Silverlight 2 in depth.

For some business applications with more advanced reporting requirements, CSS print stylesheets might not be enough. In those cases you could use the HTML Bridge to invoke JavaScript to open up a new browser window containing a server side generated report. The report could be any document, such as a PDF or XPS file, or simply an HTML page rendered on the server. Since the rendering is happening on the server you are free to choose any technology or reporting framework to create your reports.

Summary

With the recent release of Silverlight 2, now is a great time to start considering Silverlight 2 for your line of business applications. With .NET running in the browser and a powerful presentation model, you now have the building blocks needed to build compelling Rich Internet Applications for use internally or externally on the Internet. Silverlight 2 is a young piece of technology so best practices and patterns are still emerging. Thankfully the similarity with WPF gives us a great starting point, and already application frameworks like Prism and CSLA.NET are being ported over to Silverlight 2. I also expect Microsoft to start adding value on top of Silverlight 2 in terms of application frameworks, reference implementations, and sample applications.

Tuesday, November 25, 2008 5:25:24 PM (W. Europe Standard Time, UTC+01:00)
Love the Silverlight blogging! Keep it coming. I’m developing SL business apps in a Fortune 500 company and your blog is invaluable.

Some of my colleagues are balking at SL because of data access. I’m wondering if you can respond?

So, the question is how efficient is the offline to online database synchronization API from Silverlight? In fact, there is none. Having an offline database(with a solid and easy to use data synchro API) is important because pulling data from an online database for each action is costly in itself and SL being a "client-side" web technology should have solved that . Point is, if I had to go the server then I would just write an ASP.Net app with cool controls and Ajax and I am done. I look at RIA from a data angle and not snazzy look and feel only. Without this piece, Silverlight is no better than Flash.

In any case, the client storage of data with Silverlight is simply one piece of the puzzle.

To expand on a two-pronged problem -
Couple of things that Google Gears API (or similar, if any other are available) attempt to solve is -
1. Direct access to the database - no serialization cost. Currently, you have to save object as XML like so serialization/deserialization costs but will give SL a pass on this…-
http://pietschsoft.com/post/2008/10/Silverlight-Client-Side-Database-via-LINQ-and-Isolated-Storage.aspx
However, with Gears you can access the database directly through an old-style lightweight recordset.

Here is the main issue -
2. Background Synching (synch offline database with online database with delta) through WorkerPool API from Gears. This is the crux of the matter.
For SL 2.0 - Some people are handcoding hacks for this (and that too for only SQL Server). Like so, http://www.codeproject.com/KB/silverlight/MySilverlightDataApp.aspx#Why%20WCF,%20Cant%20I%20access%20the%20db%20directory?

We do not know if the above hack works even and/or how efficient is it.
Or this - http://blogs.msdn.com/swiss_dpe_team/archive/2008/04/04/crud-operations-with-optimistic-locking-using-silverlight-2-beta1-WCF-and-LINQ-to-sql-inserts-updates-and-deletes.aspx

Also, what would be the cost of the hack in itself?

Hence, for my decision maker colleagues, SL is still not ready for heavy duty enterprise class LOB applications unlike WPF is.

One a side note, the PDC session on developing SL business apps is worth a watch. Note the cool login control that is coming our way. http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV-HQ/PC11.wmv


Rich
Wednesday, November 26, 2008 5:38:25 AM (W. Europe Standard Time, UTC+01:00)
Why is offline DB that much of an issue?
We didn't have good sync options before and SyncServices (or similar) are not even used for most of the LOB apps. What's the issue of not having something like that in SL.

I think there're so many missing pieces, but I don't think this is a critical one, most apps don't need and most LOBs frameworks don't offer a solution to this problem either.

By the other hand, there are a lot of bugs in the controls that make me want to go back to VB6, where they have a drop down list that worked and a data grid that renders properly.
Wednesday, November 26, 2008 1:17:03 PM (W. Europe Standard Time, UTC+01:00)
The way I see it is that for LOB applications, XBAP has always been there. This is because in organisations with over 10,000 client workstations, they have a standard master and updates infrastructure; in other words, they have WPF on the client. Or I can rollout a fat client or use ClickOnce.

Silverlight is therefore about RIA and cross-browser compatibility. It’s for Joe Public. But, Joe Public may be a private client of Company A. It may be an oil company pension fund using an investment bank’s dealing systems. And so, Silverlight offers nothing more than ASP.NET.

Or does it? The question really is about what you can achieve with RIA that you could not before. What is the competitive advantage to me? I imagine that I’m heading the Corporate Client Services division of Goldman Lynch...

If I can move forward with Silverlight as it grows I may be able to represent a client’s data in 3D and allow them to execute orders using that immersive experience. I can make that derivatives dealing environment for my customers without having to hire Java people.

Or maybe I can represent a workflow moving down a pipeline, visually (like with the Sql Server Integration Services designer), that I cannot achieve with ASP.NET.

Arguably, I can do this with other technologies, but with Silverlight I can leverage my existing team of .NET developers and plug right into the WCF services the guys have been putting together in Hong Kong.

Silverlight enables richness and what that enables for a business is left to your imagination. One must consider that consumers/users and employees are the same, and therefore as improvements are made in UI experience of consumer goods, business tools must not lag far behind.
Luke Puplett
Friday, November 28, 2008 5:00:35 AM (W. Europe Standard Time, UTC+01:00)
First, thanks for some great thoughtful comments all three!

Rich: Regarding off line database storage and synchronization it is a valid comment to make. The Silverlight Isolated Storage is plain files, and does not provide any relation database scheme. The link to the blog post describing a serialization based DB is interesting - but wouldn't be comparable to something like Google Gears that is driven by SQLLite.

The VistaDB guys did some blogging about an early prototype of VistaDB running inside Silverlight using Isolated Storage for storing the database. This is an interesting scenario. Microsoft also has the SQL Compact Edition, which is just a DLL you reference to create file based databases. This has not been ported to Silverlight yet - but I wouldn't be surprised if that happened...

I have to agree with Miguel that this might not be a huge issue for many, as more and more people are moving towards a SOA oriented architecture where they are using a server-client communication model, and not a direct DB model. But if your scenario involves allot of synchronization and off line reference data, then a DB in Silverlight might be interesting.

Luke: I agree that the ability to come up with new interesting scenarios for business apps is one of the strengths of Silverlight. I also think the productivity is a key factor. As the expectations and requirements from business users get higher, as a result of using high quality Web 2.0 sites, the internal IT department has to deliver similar experiences internally. Doing that using just JavaScript and HTML is possible, but will probably require more effort and skills not available within most enterprises. Silverlight will make it easier to provide Richter Internet applications. Some of the scenarios you bring up are good examples where Silverlight would do a good job.

I also think Silverlight makes sense for companies delivering software through a Software+Services model, and have to support both Windows and MAC, and where broad reach is important.
Monday, December 01, 2008 12:21:55 AM (W. Europe Standard Time, UTC+01:00)
Silver light is really good and I know it as I am using it since the time it has been launched and when I got to know that silver light 2 is going to be launched I was very happy.
Monday, December 01, 2008 1:22:16 AM (W. Europe Standard Time, UTC+01:00)
About SQL CE I was talking about that the other day with a colleague and I think this will be a product hard to migrate, since we don't really have 'managed' providers, SQL CE ADO.NET objects are mainly wrappers to their ADO native providers. It could be done, but I'm sure it's not an easy task. I've not heard any plans of doing it, altough it would be a great option.

About VistaDB I didnt know they were prototyping it. Great news. Another option would be to use Google gears.

This weekend I was looking at DB4O (an object database) written in C#. This might be a bit easier to migrate. Altough the team hasn't said anything I heard of people doing it.
Monday, December 01, 2008 1:45:23 AM (W. Europe Standard Time, UTC+01:00)
Miguel: Good point about portability of SQL CE. But I thought that the most current SQL Compact Edition (not Mobile edition) was a 100% managed code embedded database... But you are probably right.

But there has a been a really increasing interest in small embedded databases lately. The DB4O project you are mentioning is one example. SQLLite, which is now heavily used on the iPhone is another good example. I'm not sure how portable it is to managed code - but the point is that you do have access to file streams in Isolated Storage, and you have a substantial part of the core .NET framework available, so it should be feasible to build a compact database.

Google Gears is another option - but currently it only got JavaScript API's and you would have to do allot of JavaScript interop. The second problem is that you would get a dependency on two browser plug-ins, which might be too much to swallow for many...

But interesting discussion.
Tuesday, December 02, 2008 11:59:08 PM (W. Europe Standard Time, UTC+01:00)
The SQL CE always worked on the desktop, it was only a license restriction that didn't allow us to use it alone, its use was restricted to dev and to boxes with SQL Server Standard or above isntalled. By SQL CE 3.1 or 3.0 they removed the restriction, but they didn't change anything. I'm not sure if they did later.

DB4O is written in C#, so it's a good candidate for an esay migration (I think). The only problem is that we're running in the sandbox and most (or all) compact DBs implementation have dependencies to native code/components.

I found a few days ago a post that talks about an implementation of a "ClientDB" that basically serializes your objects in XML and saves them in Isolated Storage.
http://pietschsoft.com/post/2008/10/Silverlight-Client-Side-Database-via-LINQ-and-Isolated-Storage.aspx

It's good as a concept, but the XML serialization would be far from efficient and still requires a lot of plumbing.

I've been writting a "ClientDB"/ObjectDB/PersistFramework I don't know how to call it, that basically allows you to define a "schema" on top of your object model to do efficient queries and it will take care of saving everything on IsolatedStorage, create hash maps (as indexes) to apply wheres/joins, track changes to objects to add/delete other business entities (e.g. if you add an order with a new customer it updates the hash map for customer so later you could look for that customer by name).
That said, it's not completely working yet and I'm not sure I'd have it ready soon, but if someone is interested I could share what I've at the moment.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910