C# 版本中存在Threadstateexception,但未调试
每当我试图打开一个文件对话框时,我都会得到未处理的C# 版本中存在Threadstateexception,但未调试,c#,debugging,release,thread-state,C#,Debugging,Release,Thread State,每当我试图打开一个文件对话框时,我都会得到未处理的threadstateexception。 我只有在使用发布设置运行VisualStudio(2012)时才得到它,当我更改回调试时,一切似乎都按预期工作。 应用程序在最后一行上崩溃,ShowDialog() 我做错了什么?是否存在代码错误,或者VS中是否缺少某些设置 我已经从调试中复制了我正在使用的所有子文件,以便发布它。 我已经尝试过搜索这个问题,但是我的谷歌fu缺少 一些裁剪代码: [STAThread] public static voi
threadstateexception。
我只有在使用发布设置运行VisualStudio(2012)时才得到它,当我更改回调试时,一切似乎都按预期工作。
应用程序在最后一行上崩溃,ShowDialog()代码>
我做错了什么?是否存在代码错误,或者VS中是否缺少某些设置
我已经从调试中复制了我正在使用的所有子文件,以便发布它。
我已经尝试过搜索这个问题,但是我的谷歌fu缺少
一些裁剪代码:
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
public static bool compareListViewWithFile(int listViewIndex)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Comma Separated Value files (.csv)|*.csv|All Files (*.*)|*.*";
openFileDialog1.FilterIndex = 1;
if (currentListView.Items == null || currentListView.Items.Count == 0)
{
openFileDialog1.Title = "Choose first file";
DialogResult userClickedOK = openFileDialog1.ShowDialog();
// etc
}
}
可能您的调试配置也是错误的,这是未定义的行为。添加lineControl.CheckForIllegalCrossThreadCalls=true
到Main函数的开头以检查此项。@Alex我已添加控件。CheckForIllegalCrossThreadCalls=true;大体上,但我看不出有什么不同。