The first thing I see is that ConvertFrom and ConvertTo both should return true for Int64. So it should look like:
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
// any integer type is accepted. No fractional types like float/double.
switch (sourceType.FullName)
{
case "System.Int64":
return true;
default:
return false;
}
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
// any integer type is accepted. No fractional types like float/double.
switch (destinationType.FullName)
{
case "System.Int64":
return true;
default:
return false;
}
}
Then at ConvertFrom (where I guess the exception is originating), I don't see any obvious error, maybe some value at your DB is greater, maybe. You should debug the application and see what is the problematic value where the exception is occurring.