c# - .NET ImageList becomes corrupt occasionally -
With a Winforms .NET application, we get an issue where an image list gets corrupted from time to time. Corrupt from
I mean that the count of number of images will be wrong and / or the images may have been replaced by system images (like dialog box mouse).
For example, the screenshot below shows the Image list on that form Which is opened frequently during the user's use. The use of a tab control on the image list form. This problem occurs only occasionally, anywhere between 5 and 20 times the form is opened. ImageList is designed by the designer to load the code, and uses images from resources: To create the imagelist, the designer is not used anywhere else in addition to the .cs code and wire it to the tab control (except for the trapping line in the virus). Thoughts? We're stuck on this and Google is not much of a turn. imageInfoCollection field correctly tracks the number of images you have in the image list. The property tracks the number of pictures that are actually in the original Windows imaginative control. There is only one way that the values can be a mismatch which I can think of. Your program is leaking GDI object handles The most common problem in Winform Apps is that it works for a long time unless you can not reach the operating system quota for this kind of handle, after you consume 10,000 in Windows Allows you to do more. Error checking in the .NET wrapper class is not completely kosher, so it can happen that the exceptions are generated without exception. When you hit that boundary, then you will see some more strange painting artifacts. You can get a basic diagnosis from the Task Manager, Process tab. Select View + Column and Tick GDI Object and User Object. When you run programs like a user, inspect these values, a fast climbing value for GDI objects gives a message of doom that is an indication that you use to settle the system Forget to use the statement. And the garbage collector is often not enough to keep you out of trouble, so the counter is stagnant but says, more than any hundred hundred objects need to fix it in your code. A fast climbing value for user objects is also a lot common is the winform bug. This is a very fatal, it will also jack up the GDI object count and GC will be the problem Can not heal This will happen when you remove control in your code with control. Remove / et () or control Forget about clearing clear () and extracted control objects. imageInfoCollection showing the correct number, but the count indicates the wrong number.
this.imageListCallTakingScreen.ImageStream = ((System.Windows .Forms.ImageListStreamer) (resources.GetObject ("imageListCallTakingScreen.ImageStream"))); This.imageListCallTakingScreen.TransparentColor = System.Drawing.Color.Transparent; This.imageListCallTakingScreen.Images.SetKeyName (0, "spinner.png"); This.imageListCallTakingScreen.Images.SetKeyName (1, "recommend-star.png"); This.imageListCallTakingScreen.Images.SetKeyName (2, "Recommended-Star_RDADN"); This.imageListCallTakingScreen.images.SetKeyName (3, "Recommended-Star - Transparent .png"); This.imageListCallTakingScreen.images.SetKeyName (4, "Initialisation_fail16.png"); This.imageListCallTakingScreen.Images.SetKeyName (5, "info_white.png"); This.imageListCallTakingScreen.images.SetKeyName (6, "check-icon .png");
Comments
Post a Comment