[英]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中得到了一个NullRefernceException-我什至都没有改变-它可以正常工作-现在它不起作用:
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.