2015-07-29 1 views
1

Am перед указанной ниже ошибки в общий ресурс 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

Я просто понял это ..

я получаю значение без проверки, если он находится в списке или нет ..

я сделал чек кол ..

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

 Смежные вопросы

  • Нет связанных вопросов^_^