I get the below exception when I try to add/insert/remove to a collection (or any operation that changes the collection).
The collection is initialized and the item inserted is not null and of the same type as the collection T.
Can any one give me a clue as to why this happens?
The runtime has encountered a fatal error. The address of the error was at 0x60f41744, on thread 0x231c. The error code is 0x80131623. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
The collection is an ObservableCollection and I managed to get down to know that it happens on the notify part of the collection changed.
This happens on the UI thread inside a task with the TaskScheduler.FromCurrentSynchronizationContext() option.
The weird thing is if I remove this (TaskScheduler.FromCurrentSynchronizationContext()) option the add/insert/remove action, all seems to work good.