什么会导致我的应用程序无法访问资源 (.resx) 文件
在终端服务器上运行的 Winforms C# 应用程序。 按钮和菜单项的所有图像都作为资源存储在 .resx 文件中。 经过一些频繁使用后,在使用系统时打开和关闭窗口,会抛出“索引超出范围”异常,并且窗口不再打开。 如果用户尝试导航到系统的任何其他部分,也会因同样的原因而失败。 将范围缩小到无法再加载的资源。
有谁知道可能导致这种情况的原因或我如何避免这种情况? 我应该使用不同的方法来存储要用于我的应用程序的图像吗?
附加信息:事实证明,用户收到的是“参数无效”异常,而不是索引超出范围。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用完资源后会释放它们吗? 听起来您的资源句柄已经用完了(您看到的异常可能是转移注意力)。
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).
奇怪的是,您在访问资源时收到超出范围的异常,主要是因为资源不存储在任何类型的集合中,而是作为属性访问,所以也许您的异常不是来自那里?
请提供一些有关检索图像/按钮的方式的代码。
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.