"Value cannot be null. Parameter name: element" when calling into DataPortal.Create method"Value cannot be null. Parameter name: element" when calling into DataPortal.Create method
Old forum URL: forums.lhotka.net/forums/t/7430.aspx
SethSpearman posted on Sunday, August 09, 2009
Hello,
I have a new business object class where I am getting the error ""Value cannot be null. Parameter name: element" when calling into the Create method of CSLA framework. Here is the shared function
--------------------
Friend Shared Function GetGroupMemberInfo(ByVal dr As SafeDataReader) As T
Dim child As T = DataPortal.Create(Of T)()
child.Fetch(dr)
Return child
End Function
-------------------
The first line in the method is where I get the error.
Here is the call stack...
---------------------
" at System.Attribute.IsDefined(MemberInfo element, Type attributeType, Boolean inherit) at Csla.DataPortal.RunLocal(MethodInfo method) at Csla.DataPortal.Create(Type objectType, Object criteria) at Csla.DataPortal.Create[T]() at GoodMins.MeetingMgr.BizObjects.GroupMemberInfoBase`1.GetGroupMemberInfo(SafeDataReader dr) in C:\\GroupMemberInfoBase.vb:line 184"
---------------------
Thanks for your help.
Seth B SpearmanRockfordLhotka replied on Tuesday, August 11, 2009
Which one is line 184?SethSpearman replied on Tuesday, August 11, 2009
Sorry for the lack of details.
In this case the BOs I am working on are a RootList of type GroupMembersList which is populated with GroupMemberInfo objects. Both of these classes are derived from code-genned BASE classes. So GroupMemberList derives from GroupMemberListBase and GroupMemberInfois derived from GroupMemberInfoBase.
In this case the error is in GroupMemberInfoBase. The call to here is being made in the enumerator of GroupMembersListBase that loads each item.
Here is the create method of GroupMemberInfoBase:
<RunLocal()> _
Private Sub DataPortal_Create(ByVal criteria As Object)
End Sub
Something tells me that I the issue is with the Criteria object or the way I am using it. But I have compared the classes to some of my others and they look the same. But, unlike the others, this one is derived from ReadOnlyBase rather than BusinessListBase.
Thanks.
Seth B Spearman
RockfordLhotka replied on Tuesday, August 11, 2009
If you put a breakpoint in the first line of your
DataPortal_Create() method does it get there? If so then the problem is almost
certainly in your code. If not, then the data portal is somehow confused.
SethSpearman replied on Tuesday, August 11, 2009
Rocky,
Thanks for your help. I am positive that the issue is with my code...not the framework. That said...I am not sure what the issue is or how to debug it.
The direct answer to your question...the code breaks at ...
Dim child As T = DataPortal.Create(Of T)()
and never hits DataPortal_Create.
Seth
PS you are a genius. I love CSLA framework.
RockfordLhotka replied on Tuesday, August 11, 2009
Assuming this is all your live code, then your problem is that you are calling
DataPortal.Create(Of T)()
but are implementing
DataPortal_Create(ByVal criteria As object)
Notice that the parameters don't line up.
I'd have expected the data portal to throw a method not found exception, but I suspect this is your problem nonetheless.
SethSpearman replied on Tuesday, August 11, 2009
Thanks Rocky.
Seth
SethSpearman replied on Tuesday, August 11, 2009
That was it.
Thanks.
Seth
Copyright (c) Marimer LLC