General Silverlight Questions

6 posts, 1 answers
  1. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 22 Feb 2010 Link to this post

    Hi,

    I'm currently using Telerik controls for my ASP.Net application and am thinking about migrating it to Silverlight.

    In order to make my application responsive I have got the main menu running on a page and then that populates an IFrame with the relevant page that the user chooses from the menu.  None of this nonsense with master pages to slow the app down or create extra server side session vars.  The concern that I have with a silverlight installation is that I want the site to not only look good but to be responsive and fast loading.

    From what I've seen of silverlight you end up with a monster application that downloads to the client browser after every change to it or client cache wipe.  To avoid the monster download I would want my Silverlight pages to be downloaded on a page by page basis.  Is that possible?  I release some updates to my application pretty much every day so the last thing I want is for each user to have to download a big file with changes to pages that they might even not even use....

    Does anyone know of any good websites that discuss the best way to develop a big web application in Silverlight?  I think that that is my main worry about switching.

    Also has anyone had experience with delivering Silverlight side by side with a normal ASP.Net app - any pointers?

    Regards,

    Jon
  2. Answer
    David Stanfield
    David Stanfield avatar
    11 posts
    Member since:
    Feb 2010

    Posted 22 Feb 2010 Link to this post

    One thing that would help with your 'monster application' concern is using MEF, the Managed Extensibility Framework (part of the Silverlight framework in version 4), to dynamically load pages. Silverlight applications download one (or more) XAP files to the client (bascially just ZIP files with a .xap extension) when the page hosting the application is requested. With MEF 'lazy loading', you can separate your app (pages) into separate assemblies, which end up creating separate XAP files.

    This post by Brad Abrams has an example (and sample app download) for doing so:

    http://blogs.msdn.com/brada/archive/2009/07/31/silverlight-3-navigation-dynamically-loaded-pages-now-mef-powered.aspx

    This technique can be used to make the app start up faster for the user, and has the side benefit of starting up faster in your development environment as well. This means less time waiting for the app to appear in the browser each time you Ctrl+F5 or F5 during the day (which is probably *many* times).

    If you use this technique, I'd recommend removing your HTML-based navigation and IFrame approach and making it all one Silverlight app (with navigation included).

    David
  3. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 22 Feb 2010 Link to this post

    Many thanks for that David, certainly good to know that there is a way around my biggest concern about silverlight (other than the fact that I'll need to learn it!).

    I'm a little confused re the version of Silverlight that this works with,  you said it's new in ver 4 but the article seems to imply that it works in 3.  Is it unofficial in 3?

    Regards,

    Jon
  4. David Stanfield
    David Stanfield avatar
    11 posts
    Member since:
    Feb 2010

    Posted 23 Feb 2010 Link to this post

    I'm not positive, but I believe that MEF (the Managed Extensibility Framework) existed as a side project to Silverlight 3, kind of like what Prism is, but then became part of the base Silverlight framework in version 4. I may be wrong about that though, this may have happened in version 3.

    As with any framework, MEF can get rather powerful, but when you start into learning it keep in mind that there are two main things about MEF, Imports and Exports. If you have a set of widgets that you want to dynamically load in a dashboard, for example, those would be flagged as exports (via the Export custom attribute). The UserControl that wants to load them then needs to simply import them by having some sort of collection property flagged with the Import custom attribute, and then you need to call PartInitialize.SatisfyImports. This is what goes out, finds those exports (widgets), and imports them into you collection.

    If you're wondering whether to use MEF or Prism, in some ways they do some similar things, but Prism is generally suited to very large applications with lots of pages, and numerous teams developing different parts (modules) of the application. I'm using MEF because my application is not huge, and I am the only developer working on it.

    Have fun learning MEF! Keep in mind that every new framework is a bit intimidating at first, but once you get the hang of it it's not so bad.

    Ross
  5. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 24 Feb 2010 Link to this post

    Sounds like I've got my work cut out for me then.

    When you say huge how many pages do you consider to be huge?  It's only me working on it but I'm currently running at maybe 150 pages with the full application taking as many as 500 or so.  Obviously I'll need to be careful choosing if Prism is more suited to that size.

    I'm only having a basic try at this so far as I'm waiting until I get hold of VS 2010 proper (have the beta). 

    Have you found any issues with users getting the silverlight framework installed - IT dept refusal to install etc?

    Regards,

    Jon
  6. David Stanfield
    David Stanfield avatar
    11 posts
    Member since:
    Feb 2010

    Posted 24 Feb 2010 Link to this post

    I would consider 150-500 pages to be in the 'rather large' range, so Prism may be a good fit. I'm under 50 and MEF is working out quite nicely for me, but I'm not sure how well MEF is suited to projects of your size. You may want to post that question on something like StackOverflow. By the way, the main dude on the MEF project (Glenn Block) used to work on Prism for the Patterns & Practices team.

    Prism is also good for situation where different teams are working on different components of the appliations (basically working in 'silos').

    Having the SL plugin installed is still a concern that must be taken into consideration, but I have a hunch that if Microsoft announces that the Windows Phone 7 will be 'all about Silverlight', it will not be long before everyone is on the Silverlight bandwagon and the installed base and developer adoption rises dramatically.

    David Ross
Back to Top