Fastmember exception: Specified argument was out of the range of valid values. Parameter name: name

fastmember outofrangeexception sqlbulkcopy

Question

I've been encountering this error Specified argument was out of the range of valid values. Parameter name: name

When im almost just copying the example here https://code.google.com/p/fast-member/

The error happens on the bcp.WriteToServer(reader), been looking for additional information but i still dont know what is causing the problem and the example is so simple... And i dont even know where the parameter named name is coming from.

My actual code is below

        using (var bcp = new SqlBulkCopy(configvalue1))
        using (var reader = ObjectReader.Create(DataToLoad, new string[]{"id","field1","field2","field3"}))
        {
            bcp.DestinationTableName = string.Format(DestinationTableFormat, DestinationDb, DestinationSchema, DestinationTable);
            bcp.BatchSize = BatchSize ?? 10000;
            bcp.WriteToServer(reader);
            bcp.Close();
        }

Can someone help?

Thanks in advance

1
3
3/13/2015 5:26:01 PM

Popular Answer

For me this was caused by a mismatch between the property names on source data object and the parameter list in the reader creation step.

class Supplier
{
    public string Code;
    public string Name;
}

// version that caused the error 
using (var rdr = ObjectReader.Create(suppliers, "code", "name"))

// compared to re-cased version to match the Supplier object property casing
using (var rdr = ObjectReader.Create(suppliers, "Code", "Name"))

I had used Re-sharper which re-case the "code" and "name" properties in the Supplier object and that meant the reader couldn't map to the properties. I left the properties in the revised case and amended the reader parameter list to match as shown in the second line.

2
2/2/2017 12:07:02 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow