dotnet/machinelearning · error · ArgumentException
String.Format(Strings.MultipleMismatchedValueType…
Error message
String.Format(Strings.MultipleMismatchedValueType, typeof(long), typeof(int), typeof(bool))
What it means
When Clone receives a non-null mapIndices column, its DataType must be long, int, or bool; any other element type throws ArgumentException with Strings.MultipleMismatchedValueType listing the three supported types, paramName mapIndices. Only these three map column types have cloning implementations.
Solutions
- Convert the map to PrimitiveDataFrameColumn<long> (or int/bool) before cloning.
- Build the map explicitly: new PrimitiveDataFrameColumn<long>("indices", indices).
- Keep filter maps bool and index maps long by convention.
- Check mapIndices.DataType against typeof(long)/typeof(int)/typeof(bool) before calling Clone.
Example fix
// before
column.Clone(floatIndices); // PrimitiveDataFrameColumn<float>
// after
var longIndices = new PrimitiveDataFrameColumn<long>("indices",
Enumerable.Range(0, (int)floatIndices.Length).Select(i => (long)floatIndices[i]));
column.Clone(longIndices); Defensive patterns
Strategy: validation
Validate before calling
var t = mapIndices?.DataType;
bool ok = t == typeof(long) || t == typeof(int) || t == typeof(bool);
if (mapIndices != null && !ok) throw new ArgumentException("mapIndices must be long, int, or bool"); Type guard
bool isValidMapIndices(DataFrameColumn m) =>
m is null || m.DataType == typeof(long) || m.DataType == typeof(int) || m.DataType == typeof(bool); Try / catch
try { var clone = column.Clone(mapIndices); }
catch (ArgumentException ex) when (ex.ParamName == "mapIndices")
{ /* convert mapIndices to PrimitiveDataFrameColumn<long> and retry */ } Prevention
- Standardize index maps on PrimitiveDataFrameColumn<long>.
- Convert other numeric types to long before cloning.
- Check DataType before calling Clone.
- Avoid float/double index columns.
When it happens
Trigger: Calling Clone(mapIndices, invertMapIndices) with a PrimitiveDataFrameColumn of another type (short, byte, float, decimal, string) or any non-primitive column.
Common situations: Index lists produced elsewhere as float/double; CSV-parsed indices typed wrong; generic helper code passing whatever column it holds.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Strings.MapIndicesExceedsColumnLength
- and must be different
- nameof(groupByColumnIndex)
- string.Format(Strings.DuplicateColumnName, column.Name)
- string.Format(Strings.MismatchedValueType, typeof
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/954809b473d6fe73.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.Data.Analysis/DataFrameColumns/VBufferDataFrameColumn.cs:287
public new VBufferDataFrameColumn<T> Clone(DataFrameColumn mapIndices, bool invertMapIndices, long numberOfNullsToAppend)
{
return (VBufferDataFrameColumn<T>)CloneImplementation(mapIndices, invertMapIndices, numberOfNullsToAppend);
}
public new VBufferDataFrameColumn<T> Clone(long numberOfNullsToAppend = 0)
{
return (VBufferDataFrameColumn<T>)CloneImplementation(numberOfNullsToAppend);
}
protected override DataFrameColumn CloneImplementation(DataFrameColumn mapIndices, bool invertMapIndices = false, long numberOfNullsToAppend = 0)
{
VBufferDataFrameColumn<T> clone;
if (!(mapIndices is null))
{
Type dataType = mapIndices.DataType;
if (dataType != typeof(long) && dataType != typeof(int) && dataType != typeof(bool))
throw new ArgumentException(String.Format(Strings.MultipleMismatchedValueType, typeof(long), typeof(int), typeof(bool)), nameof(mapIndices));
if (mapIndices.DataType == typeof(long))
clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<long>, invertMapIndices);
else if (dataType == typeof(int))
clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<int>, invertMapIndices);
else
clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<bool>);
}
else
{
clone = Clone();
}
return clone;
}
protected override DataFrameColumn CloneImplementation(long numberOfNullsToAppend)
{
var ret = new VBufferDataFrameColumn<T>(Name, Length);View on GitHub (pinned to 7b76e69cf9)