Reputation: 1142
I'm trying to use Cirrious.MvvmCross.Plugins.Network.Reachability on Windows Phone 8. I have added the Network Plugin to my WP8 project and my core. The plugin bootstrapper has been added to the Bootstrap folder. I'm trying to pass an IMvxReachability in the constructor of one the dependencies of my View Model. When I run the app, I get this exception..
Failed to load ViewModel for type MyNamespace.MyViewModel from locator MvxDefaultViewModelLocator
Upvotes: 1
Views: 490
Reputation: 66882
Not all plugins and not all interfaces are available on all platforms.
Reachability
was added to iOS because it was a requirement from the App Store.
The same interface is not currently available on any other platforms.
If you need to get hold of the implementation of an interface which might not always be available, then the ways to do this currently are using:
if (Mvx.CanResolve<T>())
myT = Mvx.Resolve<T>();
or (better):
Mvx.TryResolve<T>(out myT);
There is currently an open issue (feature request) to allow optional parameters for IoC construction - see https://github.com/slodge/MvvmCross/issues/239
There are currently no open requests for Reachability - native APIs do exist (sometimes with app-capability protection flags), but most Droid and Windows apps don't test for network state...
Upvotes: 1