简体   繁体   English

NavigationService.Navigate抛出NullReferenceException WP7?

[英]NavigationService.Navigate Throwing NullReferenceException WP7?

Just Downloaded the WP7 SDK yestarday - And I'm new to Silver light - and Application development in general. 昨天刚下载了WP7 SDK-我是Silver Light的新手-总体而言,它是应用程序开发。

I'm just simply trying to Direct my user to a different page, but I have a NullRefernceException Error occur on a Line Of Code. 我只是尝试将用户定向到其他页面,但是在代码行上发生NullRefernceException错误。 The Stupid thing - the code above it is exactly the same - yet doesn't throw the error? 愚蠢的事情-上面的代码完全相同-不会抛出错误吗?

if (myISO.DirectoryExists("Logs") && myISO.DirectoryExists("DataStore"))
{
     NavigationService.Navigate(new Uri("Sign-in.xaml", UriKind.Relative));
}
else
{
     NavigationService.Navigate(new Uri("Welcome.xaml", UriKind.Relative));
     //Above Line Causes Exception^
}

Also I get an NullRefernceException in App.xaml.cs - which I haven't even changed - it WAS working - now it doesn't : 另外我在App.xaml.cs中得到了一个N​​ullRefernceException-我什至都没有改变-它可以正常工作-现在它不起作用:

PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

it should be like this 应该是这样

NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));

where is your "/" ? 您的“ /”在哪里?

Can you debug and identify which part of line throws an exception? 您可以调试并确定行的哪一部分引发异常吗?

Also if you use NavigationService.Navigate(new Uri("/Welcome.xaml", UriKind.Relative)); 另外,如果您使用NavigationService.Navigate(new Uri(“ / Welcome.xaml”,UriKind.Relative)); with "/" make sure that Welcome.xaml page is located in a root directory of the project. 使用“ /”,请确保Welcome.xaml页位于项目的根目录中。

Actually, 其实,

This problem occurs after you change the Assembly Name or Namespace in 
Project Properties.

To fix it, Delete all contents of the Bin and obj Folders and recompile. 要解决此问题,请删除Bin和obj文件夹的所有内容,然后重新编译。 see this thread . 看到这个线程

Also this is probably the reason why it worked when you created a new project. 这也可能是它在创建新项目时起作用的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WP7 - NavigationService.Navigate抱怨它没有收到对象引用。 。 。 但为什么? - WP7 — NavigationService.Navigate is complaining that it is not receiving an object reference . . . but why? WP7:从WP7的上下文菜单中的MenuItem单击处理程序中执行NavigationService.Navigate - WP7: Executing a NavigationService.Navigate from a MenuItem click handler from a Context menu on WP7 WP7 NavigationService.Navigate传递指针而不使用全局变量? - WP7 NavigationService.Navigate pass a pointer without using global variables? NavigationService.navigate无法正常工作 - NavigationService.navigate not working 为什么NavigationService.Navigate只在最后运行? - Why is NavigationService.Navigate running at the end only? NavigationService.navigate空引用异常 - NavigationService.navigate null reference exception 页面构造函数的NavigationService.Navigate - NavigationService.Navigate from page constructor Silverlight:当我调用NavigationService.Navigate时,布局会发生变化 - Silverlight: Layout changes when I call NavigationService.Navigate 从 Accelerometer.ReadingChanged 调用 NavigationService.Navigate 会引发 NotSupportedException - Calling NavigationService.Navigate from Accelerometer.ReadingChanged throws a NotSupportedException WP7导航 - NullReferenceException - WP7 Navigation - NullReferenceException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM