Missing lock in ProjectAssemblyReferenceCollection

SyntaxEditor .NET Languages Add-on for WPF Forum

The latest build of this product (v22.1.4) was released 2 months ago, which was before this thread was created.
Posted 2 months ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Version: 22.1.1
Platform: .NET 4.8
Environment: Windows 10 (64-bit)
Avatar

Hi there,

we have encuntered an exception in the class ProjectAssemblyReferenceCollection:

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at ActiproSoftware.Internal.Ov.get_Item(String  )
   at ActiproSoftware.Internal.Ov.Add(IAssembly assembly)

I have looked at the source code and found that there is missing a lock in the index overloads. While the actual insertion is secured by a lock in the base class SimpleSynchronizedCollection, the index operator uses foreach over the collection.

As a workaround I can add the locks myself, but I just wish the collections were really thread-safe and not just parts of it. With the old WinForms version we at least knew the classes were not thread-safe. But now some operations are thread-safe while others are not. And usually the problems are found by the customers or very late during development.

[Modified 2 months ago]


Best regards, Tobias Lingemann.

Comments (1)

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

For the next release we updated the SimpleSynchronizedCollection base class to include a protected TryFindItem method that includes the necessary lock and updated each of the indexed properties in ProjectAssemblyReferenceCollection to use the new thread-safe method when searching for the desired assemblies.  Thank you for bringing this to our attention.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.