ArgumentException while beginFetch

ArgumentException while beginFetch

Old forum URL:

vschaak posted on Monday, January 23, 2012


I'm running out of ideasTongue Tied

I created the following code, used to start the fetch of my own Identity-objects. Unfortunatly it results in an ArgumentException "An item with the same key has already been added". I have to use my own criteria object, because my login process needs an appname, since those security classes are used by several apps/modules and the login process is logged...

    Public Shared Sub GetmyOwnIdentity(mUsername As String, mPassword As String,
 mApplicationname As String, mCallback As EventHandler(Of 
DataPortalResult(Of myOwnIdentity)))
        Dim myCriteria As VerifyCredentialsCriteria = New 
VerifyCredentialsCriteria(mUsername, mPassword, mApplicationname)
        DataPortal.BeginFetch(Of myOwnIdentity)(myCriteria, mCallback)
    End Sub
I use CSLA 4.1 and please indulge me for not using {}; Wink

JonnyBee replied on Monday, January 23, 2012


That sounds like you are using a Dictionary in your code and call Add method with an existing "key".

Do you have a stack trace for where the error occurs?

vschaak replied on Monday, January 23, 2012

Hi Jonny,

I found the reason myself (and started banging my head against the wall):

My ClientConfig-file contains two endpoint settings, one for development purpose and the other one for production. While one has to be 'active' the other one has to be commented out (for ease of deployment). In this case I must have forgotten to comment out the other oneEmbarrassed

The fooling thing is, that this exception would have happen on any server-access, but this time it was the login with it's custom criteria object, which in fact was the first one...

Thanks and have a good time!


Copyright (c) Marimer LLC