<p>G'day,</p>
<p> </p>
<p>If you have two (or more) destinations in the one data flow, you can get an exception "An item with the same key has already been added." (see below for stack trace).</p>
<p> </p>
<p>I believe that the code within SetupMaxLengthLookup (SharePointUtility\DataObject\ColumnData.vb) needs to have a threading lock added to the creation and population of the Private Shared _columnLengthLookup field.</p>
<p> </p>
<p> </p>
<p> </p>
<p>System.ArgumentException: An item with the same key has already been added.</p>
<p> at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)</p>
<p> at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)</p>
<p> at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)</p>
<p> at Microsoft.Samples.SqlServer.SSIS.SharePointUtility.DataObject.ColumnData.SetupMaxLengthLookup()</p>
<p> at Microsoft.Samples.SqlServer.SSIS.SharePointUtility.Adapter.ListsAdapter._Closure$__1._Closure$__2._Lambda$__4(XElement l, XElement m)</p>
<p> at System.Linq.Enumerable.<JoinIterator>d__61`4.MoveNext()</p>
<p> at System.Linq.Enumerable.<UnionIterator>d__81`1.MoveNext()</p>
<p> at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)</p>
<p> at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)</p>
<p> at Microsoft.Samples.SqlServer.SSIS.SharePointUtility.Adapter.ListsAdapter.GetSharePointFields(String listName, String viewId)</p>
<p> at Microsoft.Samples.SqlServer.SSIS.SharePointUtility.ListServiceUtility.GetFields(Uri sharepointUri, String listName, String viewName)</p>
<p> at Microsoft.Samples.SqlServer.SSIS.SharePointListAdapters.SharePointListDestination.GetAccessibleSharePointColumns(String sharepointUrl, String listName, String viewName)</p>
<p> at Microsoft.Samples.SqlServer.SSIS.SharePointListAdapters.SharePointListDestination.ValidateSharePointColumns()</p>
<p> at Microsoft.Samples.SqlServer.SSIS.SharePointListAdapters.SharePointListDestination.Validate()</p>
<p> at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostValidate(IDTSManagedComponentWrapper100 wrapper)</p>
Comments: ** Comment from web user: kmartin **
Attached is a diff file to address this issue.
It locks IF the ColumnData._columnLengthLookup is Nothing, and checks that it is still nothing, and then creates and populates it.
This should prevent the race condition.