Upgrading from Silverlight 4 to 5

Apr 16, 2012 at 8:30 AM
Edited Apr 16, 2012 at 8:43 AM

Hi Tony,

What do we need to update our project from Silverlight 4 to 5. I have changed the target framework to 5; installed all the necessary tools from Silverlight.net website along with WCF RIA Services. (Updated all the references)

The project compiles fine but when I run the project, it throws an error in InjectedViewModelLocator. Is there anything I need to do or has anything changed in terms of how you create viewmodels?

Hope this is just a simple change.

Cheers!

 

Error:

XamlParseException was unhandled by user code

The invocation of the constructor on type 'Undo.Locators.InjectedViewModelLocator' that matches the specified binding constraints threw an exception. [Line: 15 Position: 45]

 

Line 15 represents the locator in app.xaml

Coordinator
Apr 16, 2012 at 11:32 AM
What exception are you getting?
Apr 16, 2012 at 1:48 PM

Hi Tony,

I get the XAMLParseException. The exception states:

XamlParseException was unhandled by user code

The invocation of the constructor on type 'Undo.Locators.InjectedViewModelLocator' that matches the specified binding constraints threw an exception. [Line: 15 Position: 45]

Any clues?

Coordinator
Apr 16, 2012 at 2:35 PM
Looks like the constructor of the ViewModelLocator is throwing an exception, and the XAML parser is encountering it. Is there an InnerException shown? Or can you set a break point in the ctor of the locator to see what is happening there? I don't know of a breaking change, but let's see what error is actually taking place.
Apr 16, 2012 at 2:41 PM

Hi Tony,

I am pretty sure there was an inner exception shown - Will post it once I get back to work tomorrow morning. Many thanks! I am just trying to compare InjectedViewModelLocator file for Silverlight 4 and 5.

Apr 17, 2012 at 1:08 AM
Edited Apr 17, 2012 at 1:12 AM

Hi Tony,

Problem Solved! I did some reading and then checked the version of the references. I found that two of the references were not updated to /pointing to Silverlight v5 folder when I changed the target framework to Silverlight 5. Removed these and added the correct references and everything seems to work fine now. Will post if I encounter any other issues with it. Hopefully this is it and I can get along with new features of Silverlight 5. 

Two references that were not updated in my case were:

 

System.Windows.Controls.Toolkit.Internals
System.Windows.Controls.Data.DataForm.Toolkit

 

Two of the features which could be useful for my project is to have a validating viewmodel and Test project incorporated in the next release. I am currently implementing INotifyDataErrorInfo in my viewmodels to validate some of the properties.

Have a great day ahead!

Coordinator
Apr 17, 2012 at 11:23 AM
Glad to hear you figured it out!

I forgot that I implemented INotifyDataErrorInfo in ModelBase and not ViewModelBase - I'll be sure to address that in a future drop.

I'll also check into bringing the Test project back into the template. I ran into a problem bringing it in and attributed that to the fact that in the Silverlight Toolkit it's classified as part of the "experimental" quality band.

Overall, I'm not a big fan of running unit tests on the Silverlight UI thread. I would much rather use something like NUnit that can run asynchronously. There's a port of NUnit for SL4, which looks promising. Does anyone have any other recommendations?

Cheers,
Tony