问题描述
下面的代码是我的悲伤中的一个(三个)的例子。这是一个简单的OpenFileDialog()调用,导致程序崩溃。在XP上,如果对话框保持打开几秒钟,则会发生崩溃。在Vista上,如果用户选择我的电脑,则会发生崩溃。在VS2008中,调试器有时会捕获stackoverflowexception。如果我把断点在第一行(新的...),vshost.exe崩溃。如果我在ShowDialog()行放置一个断点,我得到一个FatalExecutionEngineError。如果我编译没有vshost,应用程序将运行,直到随机崩溃(如在XP - 有一些时间)。
The code below is one (of three) examples of my grief. It is a simple OpenFileDialog() call which causes the program to crash. On XP, the crash occurs if the dialog stays open for several seconds. On Vista, the crash occurs if the user selects "My Computer". In VS2008, the debugger sometimes catches a stackoverflowexception. If I put a break point in the first line (new ...), vshost.exe crashes. If I put a break point at the ShowDialog() line, I get a FatalExecutionEngineError. If I compile without vshost, the application will run until a random crash (as on XP - there is some amount of time).
有两个打开的对话框打开不同类型的文件,其中所有三个都有相同的行为。类似的代码在我的其他项目中不会显示相同的行为。
There are two other open dialogs that open different types of files, all three of which have the same behavior. Similar code does not show the same behavior in my other projects.
线程公寓是单一的。我已经尝试设置ValidateNames = false。在大多数情况下,调试器正在脱离深端。
The thread apartment is single. I have tried setting ValidateNames = false. The debugger is falling off the deep-end in most cases.
OpenFileDialog imageDlg = new OpenFileDialog();
imageDlg.Filter = "All Images|*.jpg;*.jpeg;*.png;*.tif;*.tiff;*.bmp|All Files|*.*|JPEGs (*.jpg)|*.jpg|PNGs (*.png)|*.png|TIFFs (*.tiff)|*.tiff|TIFFs (*.tif)|*.tif|BMPS (*.bmp)|*.bmp";
imageDlg.Title = "Select Scan Image";
if (DialogResult.OK == imageDlg.ShowDialog())
{
updateImageDisplay();
}
// // setScratchImageButton //
this.setScratchImageButton.Location = new System.Drawing.Point(191, 15);
this.setScratchImageButton.Name = "setScratchImageButton";
this.setScratchImageButton.Size = new System.Drawing.Size(26, 23);
this.setScratchImageButton.TabIndex = 8; this.setScratchImageButton.Text = "...";
this.setScratchImageButton.UseVisualStyleBackColor = true;
this.setScratchImageButton.Click += new System.EventHandler(this.setScratchImageButton_Click);
推荐答案
在什么情况下显示此对话框的方法称为?此错误的最可能的原因是事件被多次生成并导致向用户显示 OpenFileDialog
的许多实例。它们可能被显示在彼此的顶部,给出仅一个对话的外观。
Under what circumstances is the method which displays this dialog being called? The most likely source of this error is that the event is being generated many times and causing many instances of OpenFileDialog
to be displayed to the user. They are potentially being displayed on top of each other giving the appearance of only a single dialog.
EDIT
如果只有调试器出现故障,关闭隐式函数评估到调试器属性窗口(工具 - >选项 - >调试器)。这可能是你的窗体上的一个属性导致堆栈溢出当通过调试器查看。
If it's only the debugger scenario that is failing then try turning off implicit function evaluation into debugger property windows (Tools -> Options -> Debugger). It's possible one of the properties on your form is causing a stack overflow when viewed through the debugger.
这篇关于在C#中的OpenFileDialog计算器/ CLR错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!