Winforms c# application running on terminal server. All images for buttons and menu items are stored as resources in the .resx file. After some heavy use, opening and closing windows while using the system, an "index out of range" exception is thrown and the window no longer opens. If the user attempts to navigate to any other part of the system it fails for the same reason. Narrowed it down to the resources not being able to be loaded anymore.
Does anyone have an idea of what may cause this or how I might be able to avoid it? Should I use a different method for storing my images to be used for my application?
Additional information: turns out the user was receiving a "Parameter is not valid" exception rather than an index out of range.
It is strange that you receive an out-of-range exception when accessing resources, mainly because the resources are not stored in any kind of collection, there are accessed as properties, so perhaps your exception does not come from there?
Plz provide some code about the way you are retrieving the images/buttons.
Are you releasing the resources after you use them? It sounds like you're running out of resource handles (and the exception you're seeing may be a red herring).