简体   繁体   English

找不到Kentico 9密钥名称的全局设置

[英]Kentico 9 Global setting was not found for key name

I am trying to create settings for a custom module. 我正在尝试为自定义模块创建设置。 I am upgrading from Version 8 to version 9. The code worked fine for version 8. I am testing the code on default2.aspx. 我正在从版本8升级到版本9。该代码在版本8上运行良好。我正在测试default2.aspx上的代码。 Here is my code and error: 这是我的代码和错误:

Error: 错误:

Global setting was not found for key name 'AvalaraJMALicenseKeyStartDate' 找不到键名“ AvalaraJMALicenseKeyStartDate”的全局设置

The code shows the error here: 该代码在此处显示错误:

    SettingsKeyInfoProvider.SetSettingsKeyInfo(si);

Code: 码:

    //Insert new SettingsKey into database
    string siteName = CMS.SiteProvider.SiteContext.CurrentSiteName;
    int siteID = CMS.SiteProvider.SiteContext.CurrentSiteID;
    DataSet sites = CMS.SiteProvider.SiteInfoProvider.GetSites();

    /// <summary>
    /// creates custom settings for JMA Kentico Software in settings area of site manager
    /// </summary>
    public void CreateAvalaraSettings()
    {

        //create the avalara category, if it doesn't exist
        SettingsCategoryInfo category = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("JMA.Avalara");
        if (category == null)
        {
            SettingsCategoryInfo se = new SettingsCategoryInfo();
            se.CategoryName = "JMA.Avalara";
            se.CategoryDisplayName = "Avalara";
            SettingsCategoryInfoProvider.SetSettingsCategoryInfo(se);
        }

        #region avalara settings

        //if the setting does not exist, then create it
        if (SettingsKeyInfoProvider.GetSettingsKeyInfo(siteName + ".AvalaraJMALicenseKeyStartDate", siteID) == null)
        {
            // Create and set up new SettingsKey
            SettingsKeyInfo si = new SettingsKeyInfo();
            si.KeyName = siteName + ".AvalaraJMALicenseKeyStartDate";
            si.KeyDisplayName = "AvalaraJMALicenseKeyStartDate";
            si.KeyDescription = "AvalaraJMALicenseKeyStartDate";
            si.KeyType = "string";
            si.KeyDefaultValue = DateTime.Now.ToString();
            si.KeyValue = DateTime.Now.ToString();
            si.SiteID = siteID;
            si.KeyIsGlobal = false;
            si.KeyCategoryID = category.CategoryID;
            SettingsKeyInfoProvider.SetSettingsKeyInfo(si);

        }

I removed this code and it worked: 我删除了此代码,它起作用了:

si.SiteID = siteID;
si.KeyIsGlobal = false;

暂无
暂无

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

相关问题 找不到类型或命名空间名称“Key” - The type or namespace name 'Key' could not be found 如何解决错误“在依赖类型上未找到外键名称” - How to solve error “ The foreign key name was not found on the dependent type ” 资源字典不起作用-找不到名称/密钥的异常 - Resource Dictionary not working - Exception raised for Name/Key not found 找不到转换器? XamlParseException:找不到名称/键为StringTruncator的资源 - Converter not found? XamlParseException: Cannot find a Resource with the Name/Key StringTruncator 在XAML中设置全局样式 - Setting global style in XAML AsNoTracking() 的全局设置? - Global setting for AsNoTracking()? 动态加载页面类/程序集:在全局名称空间中找不到类型或名称 - Dynamically Loading Page Class/Assembly: Type or name could not be found in the global namespace 我收到错误消息“在全局名称空间中找不到类型或名称空间名称&#39;CS&#39;(您是否缺少程序集引用?)” - I'm getting error “The type or namespace name 'CS' could not be found in the global namespace (are you missing an assembly reference?)” 在全局名称空间中找不到类型或名称空间名称“名称空间”(您是否缺少程序集引用?) - The type or namespace name '“Namespace”' could not be found in the global namespace (are you missing an assembly reference?) C# Winforms 在全局命名空间中找不到类型或命名空间名称“属性” - C# Winforms The type or namespace name 'Properties' could not be found in the global namespace
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM