I am developing an app using brokered components, using the Microsoft templates (https://visualstudiogallery.msdn.microsoft.com/527286e4-b06a-4234-adde-d313c9c3c23e) and following this step-by-step (http://blogs.u2u.be/diederik/post/2014/04/25/Building-Enterprise-apps-using-Brokered-Windows-Runtime-Components.aspx).
The reason of my problem is that I can execute/deploy the app without problems in local machine and in windows simulator, but when I deploy the app in a device it breaks with a TargetInvocationException
Description of the error:
Requested Windows Runtime type 'MyNamespace.PrintService' is not registered
I get the error in my ViewModelLocator
, in the line of code of the getter of the ViewModel which uses the brokered component:
public SettingsViewModel Settings
{
get { return ServiceLocator.Current.GetInstance<SettingsViewModel>(); }
}
The ViewModelLocator is an standard MVVM Light view model locator.
Here is the source code of my SettingsViewModel where I inject the brokered component:
public class SettingsViewModel
{
public SettingsViewModel(IPrintService printService)
{
if (printService == null)
throw new ArgumentNullException("printService");
_printService = printService;
InitializeCommands();
InitializeActions();
}
...
}