I have a very strange situation, exactly same site and code on server and developer machine. On server everything works fine, but on developer I encounter such a problem (details below). It happens if I assing a child class to parent, like:
void MyMethod(Child child, ...)
{
Parent parentElement = new Parent();
parent.Title = "Something";
parent.Child = child; //error here
...
}
Microsoft.SharePoint.SPFieldMap.GetColumnNumber(String strFieldName, Boolean bThrow) w Microsoft.SharePoint.SPListItemCollection.GetColumnNumber(String groupName, Boolean bThrowException) w Microsoft.SharePoint.SPListItemCollection.GetRawValue(String fieldname, Int32 iIndex, Boolean bThrow) w Microsoft.SharePoint.SPListItem.GetValue(SPField fld, Int32 columnNumber, Boolean bRaw, Boolean bThrowException) w Microsoft.SharePoint.SPListItem.GetValue(String strName, Boolean bThrowException) w Microsoft.SharePoint.SPListItem.get_Item(String fieldName) w Microsoft.SharePoint.Linq.PropertyMap.GetSPFieldValue(PropertyMap pm, SPListItem item, JoinPath joinPath) w Microsoft.SharePoint.Linq.PropertyMap.GetFromListItem(DataContext dc, SPListItem item, Object entity, JoinPath joinPath) w Microsoft.SharePoint.Linq.SPItemMappingInfo.MaterializeEntity[TEntity](DataContext dc, SPDataList list, SPListItem item, SPItemMappingInfo itemMappingInfo, JoinPath joinPath) w lambda_method(ExecutionScope , SPListItem ) w System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext() w System.Collections.Generic.List1..ctor(IEnumerable1 collection) w Microsoft.SharePoint.Linq.EntitySet1.Load() w Microsoft.SharePoint.Linq.EntitySet1.Add(TEntity entity, Boolean fireEvents) w Microsoft.SharePoint.Linq.EntitySet1.Add(TEntity entity)