Monday, October 6, 2014

MvxIoCResolutionException: Failed to resolve parameter for parameter pictureChooserTask of type IMvxPictureChooserTask when creating Collect-A-Bull.Core.ViewModels.AddViewModel

Problem:

Using Stuart Lodge's excellent N+1 series, I stumbled in Session N+1 - 14.  This is where the pictureChooserTask is introduced.

 I was getting this error which absolutely baffled me:

MvxIoCResolutionException: Failed to resolve parameter for parameter pictureChooserTask of type IMvxPictureChooserTask when creating  Collect-A-Bull.Core.ViewModels.AddViewModel


Solution:

I would only get this error at runtime which lead me down a path towards the solution.
Stuart reminded me that what I was missing was the bootstrap:

To make the plugin available, you'll need to reference the plugin core and touch assemblies, and you'll need to include a bootstrap class - like https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/blob/master/N-08-Location/Location.Touch/Bootstrap/LocationPluginBootstrap.cs

What I needed to add in my UI layer was the bootstrap folder with the PictureChooserPluginBootstrap class.

using Cirrious.CrossCore.Plugins;
namespace PictureTaking.Phone.Bootstrap
{
public class PictureChooserPluginBootstrap
: MvxPluginBootstrapAction<Cirrious.MvvmCross.Plugins.PictureChooser.PluginLoader>
{
}
}


Once I had this in place the viewmodel loaded correctly and I was able to proceed.


Source:
http://answer.techwikihow.com/1004999/ioc-resolving-dependencies-mvvmcross.html

https://github.com/MvvmCross/MvvmCross/wiki/MvvmCross-plugins#picturechooser

No comments:

Post a Comment