System.AggregateException: One or more errors occurred. (An item with the same key has already been added. Key: 2350882391344)
---> System.ArgumentException: An item with the same key has already been added. Key: 2350882391344
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at FreeImageAPI.FreeImage.OpenMultiBitmapFromStream(Stream stream, FREE_IMAGE_FORMAT& format, FREE_IMAGE_LOAD_FLAGS flags)
at FreeImageAPI.FreeImageBitmap.LoadFromStream(Stream stream, FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags)
at FreeImageAPI.FreeImageBitmap..ctor(String filename, FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags)
at FreeImageAPI.FreeImageBitmap..ctor(String filename, FREE_IMAGE_LOAD_FLAGS flags)
at FreeImageAPI.FreeImageBitmap..ctor(String filename)
at FreeImageAPI.FreeImageBitmap.FromFile(String filename)
Parallel.ForEach(Directory.GetFiles(dir, "*.png", SearchOption.TopDirectoryOnly), (path) =>
{
using (var bitmap = FreeImageAPI.FreeImageBitmap.FromFile(path))
{
//readonly operation
}
});
framework:
.net 6.0
both macOS and windows will get the error, but not frequently.
System.AggregateException: One or more errors occurred. (An item with the same key has already been added. Key: 2350882391344)
---> System.ArgumentException: An item with the same key has already been added. Key: 2350882391344
at System.Collections.Generic.Dictionary
2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)at FreeImageAPI.FreeImage.OpenMultiBitmapFromStream(Stream stream, FREE_IMAGE_FORMAT& format, FREE_IMAGE_LOAD_FLAGS flags)
at FreeImageAPI.FreeImageBitmap.LoadFromStream(Stream stream, FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags)
at FreeImageAPI.FreeImageBitmap..ctor(String filename, FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags)
at FreeImageAPI.FreeImageBitmap..ctor(String filename, FREE_IMAGE_LOAD_FLAGS flags)
at FreeImageAPI.FreeImageBitmap..ctor(String filename)
at FreeImageAPI.FreeImageBitmap.FromFile(String filename)
framework:
.net 6.0
both macOS and windows will get the error, but not frequently.