none
Value does not fall within the expected range

    Question

  • I created a new list in Sharepoint 2007 and developed an ASMX web service to update/add an item to the list. I am unable to test the operation using the HTTP POST protocol getting the error message: (it looks like field name or type issue?)

    System.ArgumentException: Value does not fall within the expected range.
      at Microsoft.SharePoint.SPListCollection.GetListByName(String strListName, Boolean bThrowException)
      at Microsoft.SharePoint.SPListCollection.get_Item(String strListName)
      at SharepointWebService.Service1.PASAuditAdjustments(DateTime ReportDate, Decimal BegCashIn, Decimal BegTicketsIn, Decimal BegTicketsOut, Decimal BegMnyPlyd, Decimal BegMnyWon, Decimal BegNet, Decimal BegStacker, Decimal BegDrop, Decimal BegJackPots, Decimal AdjCashIn, Decimal AdjTicketsIn, Decimal AdjTicketsOut, Decimal AdjMnyPlyd, Decimal AdjMnyWon, Decimal AdjNet, Decimal AdjStacker, Decimal AdjDrop, Decimal AdjJP, Decimal EndCashIn, Decimal EndTicketsIn, Decimal EndTicketsOut, Decimal EndMnyPlyd, Decimal EndMnyWon, Decimal EndNet, Decimal EndStacker, Decimal EndDrop, Decimal EndJackPots, String Auditor, String Explanation, Int32 Casino, String PAS)

    In another forum post, Cathy Stadler had mentioned deactivate the publishing feature to be able to access page properties. Publishing is activated, but the person who has done a lot of customization on the list has left the organization.

    1. How can I determine what will be the consequences if I deactivate publishing? Can I restore from a backup taken immediately before deactivating?

    2. What steps can I take to troubleshoot this error message? Except for the Title,which I provided a default, none of the fields require any data entry at this point.

     


    Dan Slaby
    Saturday, December 18, 2010 8:56 PM

Answers

  • This morning it all worked!?

    The title of the list was "PAS Audited Adjustments" - even though the name of the list in the url did not have spaces; when I removed the spaces, the data published today.


    Dan Slaby
    • Marked as answer by dslaby Thursday, December 23, 2010 6:43 AM
    Tuesday, December 21, 2010 5:55 PM
  • The problem is not in the spaces, problem is in the name of the list, list name in the code snippet says the list name is "PASAuditAdjustments" but the title of the List is "PAS Audited Adjustments". Difference is there is an "ed" missing in the list name.
    Aravind http://aravindrises.blogspot.com
    • Marked as answer by dslaby Thursday, December 23, 2010 6:43 AM
    Thursday, December 23, 2010 5:56 AM

All replies

  • SharePoint is unable to find the list specified in the argument, can you double check the list exist in the site?
    Aravind http://aravindrises.blogspot.com
    Sunday, December 19, 2010 5:47 AM
  • Hi dslaby,

     

    Thanks for your post.

    As I understand, you have created a custom Web Service and deployed to the SharePoint server, and now, you want to test it using HTTP Post protocol. Here are some my ideas.

    1.       There is a  “Lists web service” for you to add/update item in the list, why did you have to deploy your custom web service? More information: http://msdn.microsoft.com/en-us/library/lists%28v=office.12%29.aspx

    2.       Beside using FrontPage RPC and SharePoint RPC protocol, you can call the SharePoint web service to communicate with the server.

    3.       I don’t think it’s a good idea to deactivate the publishing feature for your test. Why not try to test in another developer machine?

    4.       Can you share the Cathy Stadler’s article, which you mentioned in your post?

     

    Best Regards,

    Wayne

    TechNet Subscriber Support in forum

    If you have any feedback on our support, please contact tngfb@microsoft.com

    Monday, December 20, 2010 1:49 AM
  • First of all I would urge you not to deactivate publishing features on your site. From the problem you describe it is very unlikely that it will fix the problem.

    To cover your second point the error message you're receiving is quite an easy one.

    "Value does not fall within the expected range" is the error message you get then trying to access an item in some sort of array or collection and the identifier you're using is "out of bounds". In terms of what you're trying to acheive this means that the list name that you're trying to access is not working.

    I assume in your .asmx file you have a web method that is doing something like:

    [WebMethod]
    public void DoSomething()
    {
     SPSite site = SPContext.Current.Site;
     SPWeb web = site.RootWeb;
     SPList list = web.Lists["List name"];
    }
    

    In this scenario what the error is telling you is that "List name" is not the correct name for the list. There are a few things to check now.

    1. Navigate to your SharePoint site and click "View All Site Content"
    2. Look at the name your list has. Copy this and paste into your code.

    In reality I assume your code to be much more complex and probably take a list name as a paramter, so you may need to look at the code that is calling your web service as well.

    Hope that helps.

    Gary...

    Monday, December 20, 2010 3:19 AM
  • I checked the list name which is correct.
    Dan Slaby: The list will add an item from the Sharepoint new form.
    • Edited by dslaby Monday, December 20, 2010 8:49 PM update information
    Monday, December 20, 2010 8:46 PM
  • For input parameters I tried decimal and float, both of which gives this error message (after changing the url to the list url). Any suggestions?

    System.ArgumentException: Cannot convert to System.Decimal.
    Parameter name: type ---> System.FormatException: Input string was not in a correct format.
      at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
      at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
      at System.Convert.ToDecimal(String value, IFormatProvider provider)
      at System.String.System.IConvertible.ToDecimal(IFormatProvider provider)
      at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
      at System.Web.Services.Protocols.ScalarFormatter.FromString(String value, Type type)
      --- End of inner exception stack trace ---
      at System.Web.Services.Protocols.ScalarFormatter.FromString(String value, Type type)
      at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
      at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request)
      at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
      at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
    

    Dan Slaby
    Tuesday, December 21, 2010 12:37 AM
  • The problems you are describing are not related.

    The value does not fall within the specified range is 100% to do with SharePoint not recognising the list name you're trying to connect to. You need to check what site/web context you're trying to access the list from. You can use a tool like SharePoint manager to browse to the site/web and list combo to ensure you're using the right values.

    Given that you're now describing the convert to system.decimal issue, I'm assuming that you've now got past the list name issue. If you could post some of the code for your web method it would be easier for us to try and work out what's causing the problem. My guess would be that one of the parameters you're passing in is null or not of the type you think and when it gets converted to decimal it throws the above exception.

    Gary

    Tuesday, December 21, 2010 1:12 AM
  • List Information

    Name: PASAuditAdjustments
    Web Address: http://server:87/Lists/PASAuditAdjustments/AllItems.aspx
    Description: Revenue audit adjustments to PAS

    Here is the code with a truncated list of variables:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using Microsoft.SharePoint;

    namespace SharepointWebService
    {
     /// <summary>
     /// Summary description for Service1
     /// </summary>
     [WebService(Namespace = "http://tempuri.org/")]
     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
     [System.ComponentModel.ToolboxItem(false)]
     // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
     // [System.Web.Script.Services.ScriptService]
     public class Service1 : System.Web.Services.WebService
     {
      string strUrl = "http://server:87/Lists/";

      [WebMethod]
      public void PASAuditAdjustments(
       DateTime @ReportDate,
       decimal @BegCashIn,
       string @Auditor,
       string @Explanation,
       string @PAS
       )
      {
       using (SPSite site = new SPSite(strUrl))
       {
        using (SPWeb web = site.OpenWeb())
        {
         web.AllowUnsafeUpdates = true;
         SPList splist = web.Lists["PASAuditAdjustments"];
         SPListItem item = null;
         SPSecurity.RunWithElevatedPrivileges(delegate()
         { 
          item = splist.Items.Add();
         });
         item["ReportDate"] = @ReportDate;
         item["BegCashIn"] = @BegCashIn;
         item["Auditor"] = @Auditor;
         item["Explanation"] = @Explanation;
         item["PAS"] = @PAS;
         item.Update();
         web.AllowUnsafeUpdates = false;
        }
       }
      }
     }
    }

     


    Dan Slaby
    • Edited by dslaby Tuesday, December 21, 2010 5:30 PM corrected server name
    Tuesday, December 21, 2010 5:21 PM
  • This morning it all worked!?

    The title of the list was "PAS Audited Adjustments" - even though the name of the list in the url did not have spaces; when I removed the spaces, the data published today.


    Dan Slaby
    • Marked as answer by dslaby Thursday, December 23, 2010 6:43 AM
    Tuesday, December 21, 2010 5:55 PM
  • The problem is not in the spaces, problem is in the name of the list, list name in the code snippet says the list name is "PASAuditAdjustments" but the title of the List is "PAS Audited Adjustments". Difference is there is an "ed" missing in the list name.
    Aravind http://aravindrises.blogspot.com
    • Marked as answer by dslaby Thursday, December 23, 2010 6:43 AM
    Thursday, December 23, 2010 5:56 AM
  • Good catch. Always something simple.
    Dan Slaby
    Thursday, December 23, 2010 6:44 AM