我有以下从 DataTable 继承的类:
public class ExcelStaticDataTable : DataTable
{
public List<ExcelStaticDataTable> SubTables { get; set; }
public ExcelStaticDataTable(string tableName): base(tableName)
{
SubTables = new List<ExcelStaticDataTable>();
}
}
当我执行以下操作时,您知道为什么我得到MissingMethodException
“为该对象定义的无参数构造函数”:
ExcelStaticDataTable table=new ExcelStaticDataTable("table1");
table.Clone();
这两段代码都在不同的dll中,只是为了澄清。这里是堆栈跟踪:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Data.DataTable.CreateInstance()
at System.Data.DataTable.Clone(DataSet cloneDS)
at System.Data.DataTable.Clone()
at System.Data.DataTable.Copy()
at ..........cs:line 35
谢谢。