MenuStrip和ToolStrip上出现“Red Cross”问题

时间:2022-04-22 00:31:59

I have a piece of software that has worked fine on many machines, althoughon one machine there is a problem that appears to occur occasionaly, the MenuStrip and the ToolStrip both appear as a blank white background with a red cross over it, as a custom control would if you created a null object. This doesn't happen whilst I am debugging and I don't know how to make the problem re-occur, but it does happen. I was wondering if anyone knew what could be the problem?

我有一个软件在许多机器上运行良好,虽然在一台机器上有一个问题似乎偶尔发生,但MenuStrip和ToolStrip都显示为一个空白的白色背景,上面有红叉,作为自定义控件如果你创建了一个null对象。这在我调试时不会发生,我不知道如何重新发生问题,但它确实发生了。我想知道是否有人知道可能是什么问题?

Would it be the version of the .NET framework?

它是.NET框架的版本吗?

Thanks

5 个解决方案

#1


This is a common occurrence when there's a GDI+ problem ("The Red X of Death"). Are you doing any custom drawing in OnPaint? Or perhaps there's a graphic resource or a glyph which is corrupt or being improperly disposed of.

当出现GDI +问题时(“死亡之红X”),这种情况很常见。你在OnPaint做任何自定义绘图吗?或者可能是图形资源或字形腐败或处置不当。

Edit: I've re-read your question. You seem to have this only on one of the machines. I've googled around a bit for this, and I stumbled upon this old thread. The post at the bottom suggests that there might be an issue with Virtual Memory turned off:

编辑:我重新阅读了你的问题。你似乎只在其中一台机器上有这个。我为此搜索了一下,我偶然发现了这个旧线程。底部的帖子表明虚拟内存可能存在问题:

We did manage to solve this - we were seeing the problem on a device running XP embedded. The XPe image developer had turned off Virtual Memory and as soon as we turned it on the problem went away. I believe it is just a symptom of the system running out of memory to display the graphics (maybe particularly if you use a lot of double buffering)

我们设法解决了这个问题 - 我们在运行嵌入式XP的设备上看到了问题。 XPe图像开发人员已关闭虚拟内存,一旦我们打开它,问题就消失了。我认为这只是系统内存不足以显示图形的一种症状(特别是如果你使用了大量的双缓冲)

Hope that helps.

希望有所帮助。

#2


Sounds like a symptom of an Out Of Memory Exception to me.

听起来像是一个Out of Memory Exception的症状。

Edit: Which can sometimes lead onto a System.InvalidOperationException: BufferedGraphicsContext

编辑:有时会导致System.InvalidOperationException:BufferedGraphicsContext

#3


Are you trying to update the GUI controls from a thread other than the GUI thread? Combine the cross thread operation with an exception handler that swallowed everything and we had the behavior you describe (on a grid control, not a menustrip bar) on an app I was maintaining.

您是否尝试从GUI线程以外的线程更新GUI控件?将交叉线程操作与吞噬所有内容的异常处理程序相结合,我们在我维护的应用程序上有你描述的行为(在网格控件上,而不是menustrip栏)。

#4


Definitively sounds like a cross-thread problem.

最终听起来像是一个跨线程的问题。

Make sure you use Invoke when accessing controls and/or firing events from a thread that is not the main UI thread.

确保在从不是主UI线程的线程访问控件和/或触发事件时使用Invoke。

#5


Seeing this happen on just one computer of more than a 1000 that have our prouducts. On that one computer I am seeing a .NET 3.5 program occassionally show the red X on its datagrid. And another far simpler .NET 2.0 program got the red X on its menuStrip. I only have source code for the simpler program but I can say that there isn't any user code at all which affects that component. No cross-thread stuff because nothing updates it. It's contents are set at development time with one item added to it at program load. The Red X failure was well after program load.

只有一台拥有我们产品的1000多台电脑才能看到这种情况。在那台计算机上,我看到.NET 3.5程序偶尔在其数据网格上显示红色X.另一个更简单的.NET 2.0程序在其menuStrip上获得了红色X.我只有简单程序的源代码,但我可以说根本没有任何影响该组件的用户代码。没有跨线程的东西,因为没有更新它。它的内容是在开发时设置的,在程序加载时添加了一个项目。程序加载后,Red X故障很好。

I was very surprised to see the problem across two different frameworks and on one program that has no data bindings. I am very wishfully hoping that the computer has its virtual memory turned off.

我很惊讶地看到两个不同框架和一个没有数据绑定的程序的问题。我非常希望电脑的虚拟内存关闭。

If it isn't that then any guidance on system parts that are shared across .NET 2.0 and .NET 3.5 would be appreciated.

如果不是这样,那么对于在.NET 2.0和.NET 3.5*享的系统部件的任何指导都将受到赞赏。

Update: The user with the problem retired the computer and replaced it (which solved the problem)

更新:有问题的用户退出计算机并更换它(解决了问题)

#1


This is a common occurrence when there's a GDI+ problem ("The Red X of Death"). Are you doing any custom drawing in OnPaint? Or perhaps there's a graphic resource or a glyph which is corrupt or being improperly disposed of.

当出现GDI +问题时(“死亡之红X”),这种情况很常见。你在OnPaint做任何自定义绘图吗?或者可能是图形资源或字形腐败或处置不当。

Edit: I've re-read your question. You seem to have this only on one of the machines. I've googled around a bit for this, and I stumbled upon this old thread. The post at the bottom suggests that there might be an issue with Virtual Memory turned off:

编辑:我重新阅读了你的问题。你似乎只在其中一台机器上有这个。我为此搜索了一下,我偶然发现了这个旧线程。底部的帖子表明虚拟内存可能存在问题:

We did manage to solve this - we were seeing the problem on a device running XP embedded. The XPe image developer had turned off Virtual Memory and as soon as we turned it on the problem went away. I believe it is just a symptom of the system running out of memory to display the graphics (maybe particularly if you use a lot of double buffering)

我们设法解决了这个问题 - 我们在运行嵌入式XP的设备上看到了问题。 XPe图像开发人员已关闭虚拟内存,一旦我们打开它,问题就消失了。我认为这只是系统内存不足以显示图形的一种症状(特别是如果你使用了大量的双缓冲)

Hope that helps.

希望有所帮助。

#2


Sounds like a symptom of an Out Of Memory Exception to me.

听起来像是一个Out of Memory Exception的症状。

Edit: Which can sometimes lead onto a System.InvalidOperationException: BufferedGraphicsContext

编辑:有时会导致System.InvalidOperationException:BufferedGraphicsContext

#3


Are you trying to update the GUI controls from a thread other than the GUI thread? Combine the cross thread operation with an exception handler that swallowed everything and we had the behavior you describe (on a grid control, not a menustrip bar) on an app I was maintaining.

您是否尝试从GUI线程以外的线程更新GUI控件?将交叉线程操作与吞噬所有内容的异常处理程序相结合,我们在我维护的应用程序上有你描述的行为(在网格控件上,而不是menustrip栏)。

#4


Definitively sounds like a cross-thread problem.

最终听起来像是一个跨线程的问题。

Make sure you use Invoke when accessing controls and/or firing events from a thread that is not the main UI thread.

确保在从不是主UI线程的线程访问控件和/或触发事件时使用Invoke。

#5


Seeing this happen on just one computer of more than a 1000 that have our prouducts. On that one computer I am seeing a .NET 3.5 program occassionally show the red X on its datagrid. And another far simpler .NET 2.0 program got the red X on its menuStrip. I only have source code for the simpler program but I can say that there isn't any user code at all which affects that component. No cross-thread stuff because nothing updates it. It's contents are set at development time with one item added to it at program load. The Red X failure was well after program load.

只有一台拥有我们产品的1000多台电脑才能看到这种情况。在那台计算机上,我看到.NET 3.5程序偶尔在其数据网格上显示红色X.另一个更简单的.NET 2.0程序在其menuStrip上获得了红色X.我只有简单程序的源代码,但我可以说根本没有任何影响该组件的用户代码。没有跨线程的东西,因为没有更新它。它的内容是在开发时设置的,在程序加载时添加了一个项目。程序加载后,Red X故障很好。

I was very surprised to see the problem across two different frameworks and on one program that has no data bindings. I am very wishfully hoping that the computer has its virtual memory turned off.

我很惊讶地看到两个不同框架和一个没有数据绑定的程序的问题。我非常希望电脑的虚拟内存关闭。

If it isn't that then any guidance on system parts that are shared across .NET 2.0 and .NET 3.5 would be appreciated.

如果不是这样,那么对于在.NET 2.0和.NET 3.5*享的系统部件的任何指导都将受到赞赏。

Update: The user with the problem retired the computer and replaced it (which solved the problem)

更新:有问题的用户退出计算机并更换它(解决了问题)