locked
Loading of the ImageList throws Exception RRS feed

  • Question

  • I have an application that is running on Application Server which is also a Terminal Server. At a time about 10-20 users are running this application. Randomly a user will get following exception on the first line of this code. It does not happen always and does not happen on development environment. Can someone please give me some idea on how to fix this problem?

    this

    .imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));

     

    this.imageList1.TransparentColor = System.Drawing.Color.Transparent;

     

    this.imageList1.Images.SetKeyName(0, "");

     

    this.imageList1.Images.SetKeyName(1, "");



    Exception System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
    System.InvalidOperationException: Loading of the ImageList did not succeed.
       at System.Windows.Forms.ImageListStreamer..ctor(SerializationInfo info, StreamingContext context)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
       at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
       at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
       at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
       at System.Runtime.Serialization.ObjectManager.DoFixups()
       at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
       at System.Resources.ResourceReader.DeserializeObject(Int32 typeIndex)
       at System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
       at System.Resources.ResourceReader.LoadObject(Int32 pos, ResourceTypeCode& typeCode)
       at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString)
       at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase)
       at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
       at System.Resources.ResourceManager.GetObject(String name)
       at Platform.Windows.Forms.Data.DataPage.InitializeComponent()
       at Platform.Windows.Forms.Data.DataPage..ctor()
       at Platform.Windows.Forms.Data.DataPage.CreatePage(String file)
       at Platform.Windows.Forms.Data.DataPageNode.get_DataPage()
       at Fastrack.IPIM.Data.ReferralEditor.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    • Moved by nobugz Saturday, July 25, 2009 10:19 AM (From:.NET Base Class Library)
    Thursday, July 23, 2009 8:25 PM

Answers

  • This crash suggests that the ImageList Handle could not be created.  This is most typically due to a process consuming all of its handle quota, 10000 on a normal Windows install.  That's most typically due to a leak induced by your code.  The classic way is to remove a control from the Controls collection and forgetting to call its Dispose() method.

    The easiest way to diagnose this is by running Taskmgr.exe, View + Select Columns and tick Handles, GDI objects and USER objects.  If my theory is correct, the latter one will steadily climb while the user is interacting with the program.  You shouldn't have too much trouble finding the problem in your code.  If you do, a memory profiler will readily show you the leaking control.  It should be visible in Spy++ as well.

    Not a BCL q, moved to Windows Forms.

    Hans Passant.
    • Marked as answer by Kira Qian Thursday, July 30, 2009 6:11 AM
    Saturday, July 25, 2009 10:18 AM

All replies

  • This crash suggests that the ImageList Handle could not be created.  This is most typically due to a process consuming all of its handle quota, 10000 on a normal Windows install.  That's most typically due to a leak induced by your code.  The classic way is to remove a control from the Controls collection and forgetting to call its Dispose() method.

    The easiest way to diagnose this is by running Taskmgr.exe, View + Select Columns and tick Handles, GDI objects and USER objects.  If my theory is correct, the latter one will steadily climb while the user is interacting with the program.  You shouldn't have too much trouble finding the problem in your code.  If you do, a memory profiler will readily show you the leaking control.  It should be visible in Spy++ as well.

    Not a BCL q, moved to Windows Forms.

    Hans Passant.
    • Marked as answer by Kira Qian Thursday, July 30, 2009 6:11 AM
    Saturday, July 25, 2009 10:18 AM
  • Hi Hans,

    I am getting the same issue while running a Web performance test using VSTS ultimate 2013 with a single user and then VSTS is crashing. May I know how to handle the issue. Do you want me to change any local host machine setting to overcome this. 

    Please help me on this.

    Thanks,

    Veeru

    Wednesday, March 4, 2015 9:16 AM