public class MyDataTable : DataTable
{
public string MyProperty { get; set; }
public DataTable MyData { get; set; }
public void MyMethod()
{
//...do some processing on itself
MyData = this;
}
}
DataTable を継承するこの MyDataTable クラスを作成しました。
public class MyClass
{
public void ProcessData()
{
MyDataTable table = new MyDataTable();
table.MyMethod();
AcceptDataTable(table); //it won't accept the table parameter.
AcceptDataTable(table.MyData); //it still won't accept the table parameter.
AcceptDataTable((DataTable)table); //it still won't accept the table parameter.
}
public void AcceptDataTable(DataTable table)
{
Service1.SubmitData(table); //actually this is where it fails. It is a WCF Service's method that takes a DataTable as parameter. It works fine if I pass a DataTable, but not MyDataTable
//There was an error while trying to serialize parameter http://tempuri.org/:dt. The InnerException message was 'Type 'SubmitData' with data contract name MyDataTable
}
}