locked
Problem with app after publishing RRS feed

  • Question

  • I've created an win8.1 app tested it on win10 device using visual studio relase and debug modes. Both worked fine. Now after i've associated the app with wp store app, created package and uploaded it the app downloaded from store crashes at one button. The button is calling RelayCommand in ViewModel with such code (through binding) but the app crashes the moment i click the button. Any ideas how can i debug it ? Like i said everything works when i'm deploying the app through visual studio, problem occurs only at the published app to the store.

            private bool _isRefreshing;
            private RelayCommand _refreshCommand;
    
            public RelayCommand RefreshCommand
            {
                get
                {
                    if(_refreshCommand == null)
                    {
                        _refreshCommand = new RelayCommand(async () => {
    
                            if (_isRefreshing)
                            {
                                return;
                            }
    
                            _isRefreshing = true;
                            RefreshCommand.RaiseCanExecuteChanged();
                            await MenuRefresh();
                            _isRefreshing = false;
                            RefreshCommand.RaiseCanExecuteChanged();
    
                        }, () => _isRefreshing == false);
                    }
    
                    return _refreshCommand;
                }
            }

    Monday, February 22, 2016 7:58 PM

Answers

All replies

  • If it works on your computer then I wonder if you've not distributed mvvmlight with it?

    Assuming that relaycommand is mvvmlight.


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Monday, February 22, 2016 8:21 PM
  • I'm not using mvvmlight framework. I just created pivot phone app project from templates for windows phone devices, in common folder it had complete implementation of RelayCommand class which looks like this.
        /// <summary>
        /// A command whose sole purpose is to relay its functionality 
        /// to other objects by invoking delegates. 
        /// The default return value for the CanExecute method is 'true'.
        /// <see cref="RaiseCanExecuteChanged"/> needs to be called whenever
        /// <see cref="CanExecute"/> is expected to return a different value.
        /// </summary>
        public class RelayCommand : ICommand
        {
            private readonly Action _execute;
            private readonly Func<bool> _canExecute;
    
            /// <summary>
            /// Raised when RaiseCanExecuteChanged is called.
            /// </summary>
            public event EventHandler CanExecuteChanged;
    
            /// <summary>
            /// Creates a new command that can always execute.
            /// </summary>
            /// <param name="execute">The execution logic.</param>
            public RelayCommand(Action execute)
                : this(execute, null)
            {
            }
    
            /// <summary>
            /// Creates a new command.
            /// </summary>
            /// <param name="execute">The execution logic.</param>
            /// <param name="canExecute">The execution status logic.</param>
            public RelayCommand(Action execute, Func<bool> canExecute)
            {
                if (execute == null)
                    throw new ArgumentNullException("execute");
                _execute = execute;
                _canExecute = canExecute;
            }
    
            /// <summary>
            /// Determines whether this <see cref="RelayCommand"/> can execute in its current state.
            /// </summary>
            /// <param name="parameter">
            /// Data used by the command. If the command does not require data to be passed, this object can be set to null.
            /// </param>
            /// <returns>true if this command can be executed; otherwise, false.</returns>
            public bool CanExecute(object parameter)
            {
                return _canExecute == null ? true : _canExecute();
            }
    
            /// <summary>
            /// Executes the <see cref="RelayCommand"/> on the current command target.
            /// </summary>
            /// <param name="parameter">
            /// Data used by the command. If the command does not require data to be passed, this object can be set to null.
            /// </param>
            public void Execute(object parameter)
            {
                _execute();
            }
    
            /// <summary>
            /// Method used to raise the <see cref="CanExecuteChanged"/> event
            /// to indicate that the return value of the <see cref="CanExecute"/>
            /// method has changed.
            /// </summary>
            public void RaiseCanExecuteChanged()
            {
                var handler = CanExecuteChanged;
                if (handler != null)
                {
                    handler(this, EventArgs.Empty);
                }
            }
    The project for my client is so small that i didn't need to attach whole mvvm framework. It's strange since runing the project from visual studio works properly (the button in the app doesn't crash the app) while generated package after submitting to store and being installed on device via store has that bug (crashing with button click). I don't know how to debug this, since i can't even display any logs from the crash or anything else.
    Tuesday, February 23, 2016 6:44 AM
  • The only thing I can think of is async.

    Change this:

         _refreshCommand = new RelayCommand(async () => {

    And make that just a regular non async command with no await and see if that makes any difference.

    With regular Silverlight 5, async await is the nuget package add on and it doesn't work.


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Tuesday, February 23, 2016 7:49 PM
  • I'v marked the wrong category it's winrt application. I've fixed the bug with the button. My application did try to save json file inside installation folder. Moving it to LocalFolder fixed the button. The problem is that it works now on my phone but doesn't even boot for my friend which wanted to try the app. Is there any way to access some logs or debug application which got installed through store ?
    Wednesday, February 24, 2016 11:01 AM
  • I think you'd still need to install some logging like for example this:

    https://code.msdn.microsoft.com/windowsapps/Logging-Sample-for-Windows-0b9dffd7

    But you should ask such questions over here:

    https://social.msdn.microsoft.com/Forums/windowsapps/en-US/home?forum=wpdevelop

    Good luck.


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    • Marked as answer by Gromcio Thursday, February 25, 2016 11:43 AM
    Wednesday, February 24, 2016 2:18 PM