Windows phone 7 导航失败时要执行的代码

Windows phone 7 导航失败时要执行的代码,windows-phone-7,Windows Phone 7,你好,我不知道该从哪里开始找。我添加了一些道具(在此之前,我的代码运行良好),然后 System.Diagnostics.Debugger.Break() 因此,我评论说这些改变,但这没有帮助 你能建议我从哪里开始寻找解决方案吗 霉菌代码: namespace SkydriveContent { public partial class MainPage : PhoneApplicationPage { private LiveConnectClient clie

你好,我不知道该从哪里开始找。我添加了一些道具(在此之前,我的代码运行良好),然后

System.Diagnostics.Debugger.Break()

因此,我评论说这些改变,但这没有帮助

你能建议我从哪里开始寻找解决方案吗

霉菌代码:

namespace SkydriveContent
{
    public partial class MainPage : PhoneApplicationPage
    {
        private LiveConnectClient client;
        FilesManager fileManager = new FilesManager();
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void signInButton1_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {

            if (e.Status == LiveConnectSessionStatus.Connected)
            {


                client = new LiveConnectClient(e.Session);
                infoTextBlock.Text = "Signed in.";
                client.GetCompleted +=
                    new EventHandler<LiveOperationCompletedEventArgs>(OnGetCompleted);
                client.GetAsync("/me/skydrive/files/");
                fileManager.CurrentFolderId = "/me/skydrive/files/"; 
            }
            else
            {
                infoTextBlock.Text = "Not signed in.";
                client = null;
            }
        }

        void OnGetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            //Gdy uda nam się podłaczyc do konta skydrive
            if (e.Error == null)
            {
                signInButton1.Visibility = System.Windows.Visibility.Collapsed;



                    infoTextBlock.Text = "Hello, signed-in user!";


                List<object> data = (List<object>)e.Result["data"];


                fileManager.FilesNames.Clear();
                filemanager.filesnames.add("..");
                foreach (IDictionary<string,object> item in data)
                {

                    File file = new File();              

                    file.fName = item["name"].ToString();
                    file.Type = item["type"].ToString();
                    file.Url = item["link"].ToString();
                    file.ParentId = item["parent_id"].ToString();
                    file.Id = item["id"].ToString();  

                    fileManager.Files.Add(file);
                    fileManager.FilesNames.Add(file.fName);

                }

                FileList.ItemsSource = fileManager.FilesNames;               
            }
            else
            {
                infoTextBlock.Text = "Error calling API: " +
                    e.Error.ToString();
            }
        }

        private void FileList_Tap(object sender, GestureEventArgs e)
        {
            foreach (File item  in fileManager.Files)
            {
                if (item.fName == FileList.SelectedItem.ToString() )
                {
                    switch (item.Type)
                    { 
                        case "file":
                            MessageBox.Show("Still in progress");

                            break;
                        case "folder":

                            fileManager.CurrentFolderId = item.ParentId.ToString(); 
                            client.GetAsync(item.Id.ToString() + "/files");

                            break;
                        default:
                            MessageBox.Show("Coś nie działa");
                            break;
                    }
                }
                else if (FileList.SelectedItem.ToString() == "..")
                {
                    client.GetAsync(fileManager.CurrentFolderId + "/files");
                }
            }
        }
    }
}
通常由于未捕获的异常而发生。
发布开始出现问题的代码,或者在遇到此问题时发布堆栈跟踪。

没有人能在看不到您正在做什么的情况下说出任何事情。

您应该检查XAML和代码中的所有URL。当您进入NavigationFailed功能时,表示手机试图导航到某个不存在的页面。如果您能告诉我们当应用程序抛出异常时您在做什么,我们将能够提供更多帮助。

异常何时发生以及代码的哪一部分。尝试使用堆栈跟踪更新您的问题。Amresh now I使用实际代码更新,应用程序停止。正如@gjulianm所回答的,由于不存在页面或页面的URI不正确,您的导航失败。请尝试在远离当前页面的任何位置检查页面的URI。
// Code to execute if a navigation fails
        private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // A navigation has failed; break into the debugger
                System.Diagnostics.Debugger.Break();
            }
        }
System.Diagnostics.Debugger.Break();