ImageList should create a copy of all the images inserted into it. Therefore, after adding them to the list, it should be safe to place the originals.
Why does the test fail below?
Bitmap test = new Bitmap(128, 128); ImageList il = new ImageList(); il.Images.Add(test); Assert.AreEqual(1, il.Images.Count); // OK, image has been inserted test.Dispose(); // now let dispose the original try { var retrievalTest = il.Images[0]; } catch (ArgumentException) // ... but this Exception happens! { } Assert.AreEqual(1, il.Images.Count); // and this will fail
What happens here is this: when trying to get an image, ImageList discovers that the original has been deleted, and removes it from ImageList.
Why is this happening, I thought ImageList should create a copy of the image?
source share