获取错误指定的参数超出了有效值的范围

时间:2015-07-29 10:43:14

标签: sharepoint sharepoint-2010 sharepoint-2013

我在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"]);
        }

有人可以告诉我我错过了什么?有时它有效,有时不是

1 个答案:

答案 0 :(得分:1)

我只是想出来..

我在没有检查它是否在列表中的情况下获得了价值..

我做了计数检查..

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