Migrating Prism based Application to Silverlight 5

Friday 30 December 2011 James G ,


I recently had to migrate a PRISM based Silverlight 4 out of browser app to Silverlight 5. (Yes we know the end is nigh but what the heck...).

The only external dependencies the application had where on
  •  Prism 4
  • Silverlight 4 toolkit

And because I was using Model View View-Model,
  •  System.Windows.Interaction.dll from the expression blend SDK.

So after all how difficult could that be?
At the time of writing this, there is no prism version specifically for Silverlight 5.


Silverlight 5 installation

First I updated my rig to Silverlight 5 by installing the Silverlight 5 Tools for Visual Studio 2010 SP1 
Then I installed the Silverlight Toolkit.

No issues so far.

I then loaded up the solution in Visual Studio and tried to compile it. WCF RIA Services then started to grumble about some “CreateRIAClientFilesTask” task failing unexpectedly.



Ok my bad. 

I had not set the target Silverlight version. I set this to 5 for every Silverlight client project in the solution.


At this point, the solution compiled successfully.  
However, when I tried to run the application another error popped up. 

The actual error message was ReflectionTypeLoadException was unhandled by user code.



At this point, I gave up and started crying like a baby.

Yeah right. I needed to show PRISM some love.

First I need to compile a version of PRISM for Silverlight 5. So I downloaded the source code for prism and rebuild it for Silverlight 5 and then replaced the PRISM references with the new Silverlight 5 ones. Then I tried again. Not working.

Dummy, I had forgotten about the Silverlight Toolkit. I replaced the Silverlight Toolkit 4 references with the Silverlight Toolkit 5 ones and tried again. Still not working.

Ahhh, System.Windows.Interaction needs to be updated as well.  Ok so I installed Expression Blend 5 beta and got a copy of this DLL and replaced it.

After that I started the app and presto it worked.

Now after some fist pumping, I have noticed a child window not correctly centred after a resize? Worked perfectly in version 4. Ok will have to fix that. Not a perfect world.

Final advice, wait for a Silverlight 5 version of PRISM if you can but then again we are in this profession because we crave the complexity...

James

2 Responses to “Migrating Prism based Application to Silverlight 5”

  • Anonymous says:

    Thanks, was considering doing this but perhaps it would better to wait for SL5 version of Prism.

  • Anonymous says:

    Download Prism 4.0, open source code solution, set all projects to SL5 and rebuild. It is so easy.


Leave a Reply

Followers

Powered by Blogger.
Powered by Blogger. Designed by elogi. Converted by Smashing Blogger for LiteThemes.com. Proudly powered by Blogger.