简体   繁体   English

“ mscorlib.ni.dll中发生了'System.ArgumentException'类型的异常”

[英]“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.

相关问题 mscorlib.ni.dll中发生类型&#39;System.InvalidOperationException&#39;的异常,但未处理 - Exception of type 'System.InvalidOperationException' occurred in mscorlib.ni.dll but was not handled mscorlib.ni.dll中发生类型为&#39;System.IO.FileNotFoundException&#39;的第一次机会异常-Windows Phone - A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll - windows phone mscorlib.ni.dll中发生类型&#39;System.Reflection.TargetInvocationException&#39;的异常,但未在用户代码中处理:Xamarin形式 - An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll but was not handled in user code: in Xamarin Form mscorlib.dll 中发生了“System.ArgumentException”类型的第一次机会异常 - A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll mscorlib.dll,类型为“ System.ArgumentException”的异常,附加信息:路径中的非法字符 - An exception of type 'System.ArgumentException' occurred in mscorlib.dll, Additional information: Illegal characters in path 抛出异常:mscorlib.ni.dll 中的“System.ArgumentNullException” - Exception thrown: 'System.ArgumentNullException' in mscorlib.ni.dll 引发异常:mscorlib.ni.dll uwp中的“ System.UnauthorizedAccessException” - Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.ni.dll uwp BLL.dll中发生了&#39;System.ArgumentException&#39;类型的未处理异常 - An unhandled exception of type 'System.ArgumentException' occurred in BLL.dll 发生类型为&#39;System.ArgumentException&#39;的未处理异常 - An unhandled exception of type 'System.ArgumentException' occurred System.Runtime.InteropServices.COMException发生在mscorlib.ni.dll中,但未在用户代码中处理 - System.Runtime.InteropServices.COMException occurred in mscorlib.ni.dll but was not handled in user code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM