当 PropertyInfo.SetValue() 遇到“Object of type 'System.Int32' cannot be converted to type 'System.UInt32'.”
判断一下类型:
if (p.PropertyType == typeof(uint))
{
p.SetValue(t, Convert.ToUInt32(row[p.Name]), null);
}
else
{
p.SetValue(t, row[p.Name], null);
}
可能相关的内容
InvalidCastException: Unable to cast object of type 'System.Boolean' to type 'System.SByte'.
C# 中对 Session 的“(string)”、“.ToString()”与“Convert.ToString”用法笔记
The cast to value type 'xxx' failed because the materialized value is null.
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.