Sitecore 8:删除语言导致KeyNotFoundException异常

时间:2016-10-19 09:50:16

标签: sitecore sitecore8

我从sitecore删除了“丹麦语”。在我的解决方案中,我得到了异常,我曾使用过代码Sitecore.Context.Language.Name

这是例外

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

整个堆栈跟踪

Source Error: 
Line 22:         static Model.Localization.CommonDictionary GetCommonLocalizations()
Line 23:         {
Line 24:             return Dictionary[Sitecore.Context.Language.Name];
Line 25:         }
Line 26:         public static string DefaultActivityTitle { get { return GetCommonLocalizations().DefaultActivityTitle; } }

Source File:  E:\IIS Data\MySite\Utilities\SF.ISK.Kernel\Localisation\CommonDictionary.cs    Line:  24 

Stack Trace: 
[KeyNotFoundException: The given key was not present in the dictionary.]
   System.Collections.Generic.Dictionary`2.get_Item(TKey key) +13763207
   SF.ISK.Kernel.Localisation.CommonDictionary.GetCommonLocalizations() in E:\IIS Data\MySite\Utilities\SF.ISK.Kernel\Localisation\CommonDictionary.cs:24
   SF.ISK.Kernel.Localisation.CommonDictionary.get_HtmlTitleTemplate() in E:\IIS Data\MySite\Utilities\SF.ISK.Kernel\Localisation\CommonDictionary.cs:136
   SF.ISK.Website.layouts.ISK.ISKMainPageLayout.GetPageTitle() in E:\IIS Data\MySite\Website\layouts\ISK\ISK.MainPage.aspx.cs:51
   SF.ISK.Website.layouts.ISK.ISKMainPageLayout.Page_Load(Object sender, EventArgs e) in E:\IIS Data\MySite\Website\layouts\ISK\ISK.MainPage.aspx.cs:41
   System.Web.UI.Control.OnLoad(EventArgs e) +109
   System.Web.UI.Control.LoadRecursive() +68
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4498

在上面的代码中,如果我将其替换为return Dictionary["en"];,那么我就不会收到错误。

1 个答案:

答案 0 :(得分:0)

您的商品可能有版本da-dk。删除da-dk版本并发布。

可能在寻找已被删除的da-dk时,sitecore无法找到此密钥。