If you get an exception while trying to make a nested query a dictionary that states a same key has already been added is there a way of actually seeing the key that is attempted to be added? In the debugger it just says the error of an key already exists with a stack trace of (I took out the actual path names):
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
at a.MainWindow.<>c__DisplayClass4a.<refreshClientLocks>b__14(DataRow acc_dr) in a\MainWindow.xaml.cs:line 301
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
at a.MainWindow.<refreshClientLocks>b__12(<>f__AnonymousType0`2 <>h__TransparentIdentifier5) in a\MainWindow.xaml.cs:line 299
at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)
at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()
Question
sathenzar
If you get an exception while trying to make a nested query a dictionary that states a same key has already been added is there a way of actually seeing the key that is attempted to be added? In the debugger it just says the error of an key already exists with a stack trace of (I took out the actual path names):
Link to comment
https://www.neowin.net/forum/topic/1014100-c-linq-exception-handling-in-a-query/Share on other sites
9 answers to this question
Recommended Posts