簡體   English   中英

獲取錯誤指定的參數超出有效值范圍

[英]Getting error Specified argument was out of the range of valid values

我在共享點2013中面臨以下提到的錯誤

Server Error in '/' Application.

Specified argument was out of the range of valid values.

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.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

給出此結果的代碼如下。

            SPList ConfigList = spWeb.Lists.TryGetList("GUID");

        SPQuery configQry = new SPQuery();

        string camlquery = @"<Where><Eq><FieldRef Name='GuidName' /><Value Type='Text'>" + guid + "</Value></Eq></Where>";
        configQry.Query = camlquery;
        SPListItemCollection ConfigItem = ConfigList.GetItems(configQry);

        if (ConfigItem != null)
        {
            if (ConfigItem.List != null)
                if (ConfigItem[0] != null)
                    result = Convert.ToString(ConfigItem[0]["Captcha"]);
        }

有人可以告訴我我在想什么嗎? 有時有效,有時無效

我只是想通了..

我在獲取價值而沒有檢查它是否在列表中。

我做了計數檢查。

 if (ConfigItem.Count != 0)
                    result = Convert.ToString(ConfigItem[0]["Captcha"]);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM