When opening a form: Failed to load ImageList

  • Thread starter Thread starter Lee Gillie
  • Start date Start date
L

Lee Gillie

When opening a non-modal dialog form which has an ImageList that I use
for a Treeview, the program crashes. This does not occur consistently,
but certainly often enough to be very annoying. It has happened two days
in a row now for one user.

The exception trace suggests to me that the .NET Framework is attempting
to extract the bitmaps from the DLL resources, or such?

It appears to be happening before any user code is being called. I have
seen others report this problem, but never a resolution. It would seem
to be a Framework bug to me. But maybe there is something I am doing?
Any clue why this could be happening, or more importantly, what I can do
about it?

************** Exception Text **************
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.InvalidOperationException:
Failed to load ImageList.
at System.Windows.Forms.ImageListStreamer..ctor(SerializationInfo
info, StreamingContext context)
--- End of inner exception stack trace ---
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, IMethodCallMessage
methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream)
at System.Resources.ResourceReader.LoadObject(Int32 pos)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean
ignoreCase)
at System.Resources.ResourceManager.GetObject(String name,
CultureInfo culture)
at System.Resources.ResourceManager.GetObject(String name)
at PPSManager.frmVolumeNavigator.InitializeComponent()
at PPSManager.frmVolumeNavigator..ctor()
at PPSManager.frmMain.PrintVolumeNavaigator(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
 
More information:

I found this article which describes the symptoms perfectly, but claims
it was a problem with Framework 1.0 SP2, and suggests it was
subsequently fixed:

http://support.microsoft.com/default.aspx?scid=kb;en-us;813967

But from the user's exception trace it would appear to me the user has
Framework 1.1 installed:
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase:
file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll

Can anyone shed light on if this problem has been re-introduced in
Framework 1.1, and if a patch is available anywhere to fix it?

- Lee
 
Lee Gillie said:
When opening a non-modal dialog form which has an ImageList that I use
for a Treeview, the program crashes. This does not occur consistently,
but certainly often enough to be very annoying. It has happened two days
in a row now for one user.

Are you using an application manifest file with "devenv.exe"?
 
Herfried said:
Are you using an application manifest file with "devenv.exe"?

No. Also, I am not deploying to XP.

But I think I found the problem, regardless. Coercing Bitmaps in an
Imagelist to an Icon seems to leak GDI resources. This was occuring for
5 small images on a polling cycle of 5 seconds. Performing all the
bitmap conversion work once at program start eliminates the leak, and
makes it more efficient at each poll/refresh anyway. When run overnight
the GDI object count was becoming staggering. Then when going to open
the form (as described above), it would then fall into the do-do left
for it.

The thing I learned this morning is the importantance of test-time
monitoring of the GDI OBJECTS COUNT in TASK MANAGER in order to detect
resource leaks in applications I am developing. I had never done this
before.

Thanks for considering this, and responding.

Best regards - Lee
 
Back
Top