locked
[W8.1]Deploying app with brokered component in physical device RRS feed

  • Question

  • 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();
            }
    
            ...
        }

    Thanks.


    Saturday, May 2, 2015 10:44 AM

Answers

  • Hi Francisco,

    Simply guess, I did not see your register code, perhaps you should add following code into your ViewModelLocator by register the SettingViewModel:

    MyNamespace.Default.Register<SettingsViewModel>();
    

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 3, 2015 9:10 AM

All replies