The View can't load the ViewModel in a Module

Topics: Prism v4 - Silverlight 4
Jul 4, 2012 at 4:20 PM
Edited Jul 4, 2012 at 4:33 PM

Basically I'm making my own version of the UICompositionQuickStart, but with some changes to match my own projects needs: RIA Services, etc..

The best way to master new technology approaches is to make my own examples.

When I try to run the project I get this XamlParseException: 

 Which translated into english means something like:

"The invocation of the constructor of type 'ModuleEmployees.ViewModels.EmployeeListViewModel' that matches the specified link restrictions throwed an exception. [Line 12 Position 42]"

Here's the corresponding View:

Here's my project structure:

Do you need some more information to know what the problem is?

I'm trying to program the Views/ViewModels without having the ViewModels as a parameter. I know that from the View Injection point of view the types are better resolved when the ViewModel comes as a parameter to the view, but I have Silverlight view that have to load the ViewModels from xaml.

Jul 4, 2012 at 6:12 PM

Hi again!

Based on my understanding, this problem doesn't seem to be related to the view or to your project structure: following the description of the XamlParseException, it seems that an exception was thrown inside the constructor of your view model. As a possible approach to check this you could set a break point inside the aforementioned constructor and debug it to find the sentence that is throwing the "real" exception.

Also, by looking at the inner exceptions shown in first screenshot you posted, it seems that the exception is related to the use of a non-initialized variable (which is probably throwing a NullReferenceException.)

I hope you find this useful,

Damian Cherubini

Jul 5, 2012 at 3:31 AM

Thank you Damian for answering. You were right.

The error message was so unfamiliar to me that I didn't know what to think of it.