Why am I getting ArgumentOutOfRangeException when constructing an ItemField? RRS feed

  • Question

  • Hey guys.  This seems like a silly little thing, hopefully it should be a snap to provide some insight (search wasn't helpful).  I've been following the simple provider sample and building out my own version.  This is in my version of CreateItemFieldDictionary().

    I have some object (Store[id].Item) and I want to get the value of some property and push it into an ItemField so Sync can do its thing.  fieldID = 1, value = 12345, it's type is int (int32).  Documentation says the exception is thrown when value is null, but that's not the case here.  Any idea what could be causing new ItemField(...) to blow up?

    // Get the value of this property and add it to the dictionary
    var value = prop.GetValue(Store[id].Item, null);
    var itemField = new ItemField(fieldID, value.GetType(), value);

    Monday, November 21, 2011 4:38 PM

All replies

  • Um.  So here's another way of looking at it:


    var itemField = new ItemField(1, typeof(int), (int)12345); // Throws ArgumentOutOfRangeException
    var itemField = new ItemField(1, typeof(uint), (uint)12345); // Works!

    Why does this happen?

    • Edited by Darlene M M Monday, November 21, 2011 6:30 PM
    Monday, November 21, 2011 6:28 PM