SL3 Problem with Resolution

Aug 17, 2009 at 2:23 AM

Hey All,

I’ve got a project I’m working on in SL3 that I’m now trying to convert over to a Prism framework. I’ve broken up all my views into modules and I’m trying to get the simplest view, a hacked down login view, to work. It’s almost exactly the same as the DiggService on the creating applications with Prism screen cast. The problem that I am having is (and again assume unless I made a typo that my project is exactly the same) when I try to run the project I get a resolution exception when the view is instantiated; the exception is on the injected ViewModel instance. Now I noticed in the screen cast that they never register the viewmodel type anywhere. My first question is is that proper?

Given the above I tried to register the ViewModel type in the IModule implementer in my Module project (in my case called BetaLogin) however the BetaLogin class is never instantiated (I put a breakpoint in the BetaLogin constructor and it is never hit). Whats going on here? Shouldn’t that class be instantiated some time before the View is constructed?

Aug 18, 2009 at 5:52 PM
Edited Aug 18, 2009 at 5:53 PM

Hi

It appears you have two different problems. I’ll try to address them separately.

The first one is your exception when trying to inject the ViewModel. If you are doing this through an interface, which I suspect is the case, you need to register the type mapping in the container before trying to resolve it:

 

container.RegisterType<IMyViewModel,MyViewModel>();

You might also find the GetRootException extension method (of the Exception class useful). You can read more about it here.

The other issue you appear to have is that the class that implements the IModule interface is not being constructed. This is usually due to the fact that the module is not being loaded. As soon as a module is loaded this class is constructed and its Initialize method is called. You can make sure the module is correctly added for download, and use the CAL bits to debug the module loading process to check why it is not loading your module.

Some links that might be useful:

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman