[英]“An exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll”
I was given a code to work on, as a beginner I didn't fully understand the code (a windows phone 8 Silverlight project using MVVM). 我得到了要处理的代码,作为一个初学者,我没有完全理解该代码(使用MVVM的Windows Phone 8 Silverlight项目)。 the code has this
代码有这个
public Dictionary<CeFlix.Entities.Enums.Views, string> PageRouting = new Dictionary<CeFlix.Entities.Enums.Views, string>()
{
{CeFlix.Entities.Enums.Views.DashboardPage,"DashboardPage.xaml"},
{CeFlix.Entities.Enums.Views.LargeBannerDetailPage,"/Views/LargeBannerDetailPage.xaml"},
{CeFlix.Entities.Enums.Views.ChannelDataPage,"/Views/ChannelDataPage.xaml"},
{CeFlix.Entities.Enums.Views.ChannelDetailPage,"/Views/ChannelDetailPage.xaml"},
{CeFlix.Entities.Enums.Views.VideoDetailPage,"/Views/VideoDetailPage.xaml"},
{CeFlix.Entities.Enums.Views.UserLoginPage,"/Views/UserLoginPage.xaml"},
{CeFlix.Entities.Enums.Views.UserRegisterPage,"/Views/UserRegisterPage.xaml"},
{CeFlix.Entities.Enums.Views.UploadVideoDetailPage,"/Views/UploadVideoDetailPage.xaml"},
{CeFlix.Entities.Enums.Views.FeedBackDetailPage,"/Views/FeedBackDetailPage.xaml"},
{CeFlix.Entities.Enums.Views.EditProfileDetailPage,"/Views/EditProfileDetailPage.xaml"},
{CeFlix.Entities.Enums.Views.ChangePasswordPage,"/Views/ChangePasswordPage.xaml"},
{CeFlix.Entities.Enums.Views.MyPlaylistDetailPage,"/Views/MyPlaylistDetailPage.xaml"},
{CeFlix.Entities.Enums.Views.SubscriptionDetailPage,"/Views/SubscriptionDetailPage.xaml"},
{CeFlix.Entities.Enums.Views.SelectedSearchItemVideoPage,"/Views/SelectedSearchItemVideoPage.xaml"},
{CeFlix.Entities.Enums.Views.CategoryDetailPage,"/Views/CategoryDetailPage.xaml"},
{CeFlix.Entities.Enums.Views.WatchLiveVideoPage,"/Views/WatchLiveVideoPage.xaml"},
{CeFlix.Entities.Enums.Views.CommentsPage,"/Views/CommentsPage.xaml"},
{CeFlix.Entities.Enums.Views.CommentsPage,"/Views/RepliesPage.xaml"}
};
I added two more pages to the project and I thought I could just add to the collection so I added two lines like this inside the PageRouting 我在项目中又添加了两个页面,我以为可以将其添加到集合中,所以我在PageRouting中添加了两行
,
{CeFlix.Entities.Enums.Views.CommentsPage,"/Views/CommentsPage.xaml"},
{CeFlix.Entities.Enums.Views.CommentsPage,"/Views/RepliesPage.xaml"}
The enum also looks like this, the last two lines represent the two new pages I added 枚举也看起来像这样,最后两行代表我添加的两个新页面
public enum Views
{
DashboardPage = 1,
LargeBannerDetailPage = 2,
ChannelDetailPage = 3,
VideoDetailPage = 4,
ChannelDataPage = 5,
UserLoginPage = 6,
UserRegisterPage = 7,
EditProfileDetailPage = 8,
FeedBackDetailPage = 9,
UploadVideoDetailPage =10,
ChangePasswordPage =11,
MyPlaylistDetailPage = 12,
SubscriptionDetailPage =13,
SelectedSearchItemVideoPage =14,
CategoryDetailPage = 15,
WatchLiveVideoPage=16,
RepliesPage = 17,
CommentsPage = 18
}
I had not seen this programming patter before. 我以前从未见过这种编程模式。 When I launch the App I an exception is thrown that say "An exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll" what do I do?
当我启动应用程序时,我抛出一个异常,说“ mscorlib.ni.dll中发生了'System.ArgumentException类型的异常'”,我该怎么办? can anyone help.
谁能帮忙。 I think it's important I post this too
我认为也要发布此帖子很重要
public void NavigateToPage(CeFlix.Entities.Enums.Views navigateToView, object navigationParameter)
{
string path = PageRouting[navigateToView];
RootFrame.Navigate(new Uri(path + "?Param=" + navigationParameter, UriKind.Relative));
}
When I now remove the two new lines of code I added to the PageRouting collection, it compiles fine, but I'm not able to navigate to those two new pages I just added. 现在,当我删除添加到PageRouting集合中的两行新代码时,它可以很好地编译,但是我无法导航到我刚刚添加的那两个新页面。
A dictionary requires unique keys, and you've added two entries with the same key - CommentsPage
. 字典需要唯一的键,并且您添加了两个具有相同键的条目
CommentsPage
。
This looks like a typo, as you've added a RepliesPage
enum value. 您添加了
RepliesPage
枚举值,这看起来像是一个错字。 Should it be this? 应该是这个吗?
{CeFlix.Entities.Enums.Views.CommentsPage,"/Views/CommentsPage.xaml"},
{CeFlix.Entities.Enums.Views.RepliesPage,"/Views/RepliesPage.xaml"}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.