I have an array of objects looking like this
public class ViewFilterData
{
public string Table { get; set; }
public string Field { get; set; }
public string Value { get; set; }
}
Due to calling function in separate dll, I need to pass this array as object[]. The above class is defined in both sections.
Project compiles, however when I try to cast each object in the array to above class, I get an invalidCastException, indicating that it "magically" know the originally class and refuse to cast it to the new one even though they are verbatim identical. Do I need to use reflection and create a new class marshalling over the array object by object and attribute by attribute? Or is there a simpler faster way? Thought about using scructs, however would rather not if possible.
"Unable to cast object of type 'Original.ViewFilterData' to type SeparateDLL.ViewFilterData'."
I call the function like this
var dt = oRepository.Page((object[])oDataRequest.Filters.ToArray())
and define it like this
public DataTable Page(object[] Filters)
object[]you should be able to sendyourtype[]without any casting