Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在winform exe中选择combobox时引发异常已更改,在调试模式下工作正常_C#_Winforms_Visual Studio 2010 - Fatal编程技术网

C# 在winform exe中选择combobox时引发异常已更改,在调试模式下工作正常

C# 在winform exe中选择combobox时引发异常已更改,在调试模式下工作正常,c#,winforms,visual-studio-2010,C#,Winforms,Visual Studio 2010,我有一个用c#编写的winform应用程序。在其中一个表单上,有一个名为“研究员姓名”的组合框。它使用MS Access表中名为“研究员信息”的tableadapters进行数据绑定,该表有两列“研究员名称”和“研究员年龄”。研究员姓名是主键 当运行创建的exe文件时,在选择此组合框中的任何值时(仅选择,此处不发生db读/写操作,我没有代码,除了使在selection changed事件上运行的按钮可见),它会抛出以下异常,表示所选组合框项已存在。有趣的是,我只是选择了一个值,并没有在db中输入

我有一个用c#编写的winform应用程序。在其中一个表单上,有一个名为“研究员姓名”的组合框。它使用MS Access表中名为“研究员信息”的tableadapters进行数据绑定,该表有两列“研究员名称”和“研究员年龄”。研究员姓名是主键

当运行创建的exe文件时,在选择此组合框中的任何值时(仅选择,此处不发生db读/写操作,我没有代码,除了使在selection changed事件上运行的按钮可见),它会抛出以下异常,表示所选组合框项已存在。有趣的是,我只是选择了一个值,并没有在db中输入值

但它在VisualStudio调试模式下运行良好。i、 e:做同样的事情不会引发任何异常

对于此特定活动,没有太多代码可显示,但是:

//在页面加载时,表适配器填充组合框

下面是表适配器的Fill方法的代码,它是默认生成的

this.research\u InfoTableAdapter.Fill(this.research\u Log\u DatabaseDataSet1.research\u Info)

公共虚拟整数 填充(研究日志数据库数据集1.Research信息数据表数据表)

{

this.Adapter.SelectCommand=this.CommandCollection[0]

        if ((this.ClearBeforeFill == true)) 

        {  dataTable.Clear();  }

        int returnValue = this.Adapter.Fill(dataTable);
        return returnValue; }
以下是异常堆栈跟踪:

**************例外文本**************

System.Data.ConstraintException:列“研究员姓名”为 约束为唯一。值“Kwek Gwen”已存在。
在System.Data.UniqueConstraint.CheckConstraint(数据行, 数据行操作)
在System.Data.DataTable.RaiseRowChangeg(DataRowChangeEventArgs args args, DataRow eRow、DataRowAction eAction、布尔fireEvent)
位于System.Data.DataTable.SetNewRecordWorker(DataRow行,Int32 proposedRecord,DataRowAction,布尔isInMerge,Int32 位置、布尔fireEvent、异常和延迟异常)
在System.Data.DataTable.SetNewRecord(DataRow行,Int32 proposedRecord, DataRowAction动作、布尔isInMerge、布尔fireEvent)
位于System.Data.DataRow.SetNewRecord(Int32记录)
位于System.Data.DataRow.EndEdit()
位于System.Data.DataRowView.EndEdit()处 在System.Windows.Forms.CurrencyManager.EndCurrentEdit()中 位于System.Windows.Forms.CurrencyManager.ChangeRecordState(Int32 newPosition,布尔验证,布尔endCurrentEdit,布尔 firePositionChange,布尔pullData)
在System.Windows.Forms.CurrencyManager.set_位置(Int32值)
在System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
在System.Windows.Forms.ComboBox.WmReflectCommand(Message&m)中
在System.Windows.Forms.ComboBox.WndProc(Message&m)中
在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m)中 在System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息和消息)
在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg、IntPtr wparam、IntPtr lparam)

下面是调试输出窗口显示的内容,在组合框单击事件期间启用了所有异常

线程“vshost.LoadReference”(0x15f0)已退出,代码为0(0x0)。 'WindowsFormsApplication1.vshost.exe'(托管(v2.0.50727)):加载'C:\Users\jollyk\documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release\WindowsFormsApplication1.exe', 已加载符号。 “WindowsFormsApplication1.vshost.exe”(托管) (v2.0.50727)):已加载 'C:\windows\assembly\GAC_MSIL\Accessibility\2.0.0.0__b03f5f7f11d50a3a\Accessibility.dll', 已跳过加载符号。模块已优化,调试器选项 “仅我的代码”已启用。 'WindowsFormsApplication1.vshost.exe' (托管(v2.0.50727)):已加载 'C:\windows\assembly\GAC\U MSIL\System.Configuration\2.0.0\Uuu b03f5f7f11d50a3a\System.Configuration.dll', 已跳过加载符号。模块已优化,调试器选项 “仅我的代码”已启用。 'WindowsFormsApplication1.vshost.exe' (托管(v2.0.50727)):已加载 'C:\windows\assembly\GAC_32\System.Transactions\2.0.0.0__b77a5c561934e089\System.Transactions.dll', 已跳过加载符号。模块已优化,调试器选项 “仅我的代码”已启用。 'WindowsFormsApplication1.vshost.exe' (托管(v2.0.50727)):已加载 'C:\windows\assembly\GAC_32\System.EnterpriseServices\2.0.0\uu_b03f5f7f11d50a3a\System.EnterpriseServices.dll', 已跳过加载符号。模块已优化,调试器选项 “仅我的代码”已启用。 'WindowsFormsApplication1.vshost.exe' (托管(v2.0.50727)):已加载 'C:\windows\assembly\GAC_32\System.EnterpriseServices\2.0.0\uu_b03f5f7f11d50a3a\System.EnterpriseServices.Wrapper.dll', 已跳过加载符号。模块已优化,调试器选项 已启用“仅我的代码”。线程“”(0x1248)已退出 使用代码0(0x0)。线程“”(0xd84)已使用代码退出 0(0x0)。单步执行:单步执行非用户代码 “System.Windows.Forms.ComboBox.OnSelectedIndexChanged”步骤改为: 跳过非用户代码 “System.Windows.Forms.NativeWindow.DebuggableCallback”进入以下步骤: 跳过非用户代码 “System.Windows.Forms.Control.ReflectMessageInternal”进入: 跨过非用户代码“System.Windows.Forms.Control.WmCommand” 单步执行:单步执行非用户代码 “System.Windows.Forms.Control.WndProc”单步执行:单步执行 非用户代码“System.Windows.Forms.Form.WndProc”单步执行:单步执行 在非用户代码之上 “System.Windows.Forms.NativeWindow.DebuggableCallback”进入以下步骤: 跳过非用户代码 “System.Windows.Forms.NativeWindow.DefWndProc”单步执行:单步执行 通过非用户代码“System.Windows.Forms.Control.WmCommand”进入: 跨过非用户代码“System.Windows.Forms.Control.WndProc” 介入
        if ((this.ClearBeforeFill == true)) 

        {  dataTable.Clear();  }

        int returnValue = this.Adapter.Fill(dataTable);
        return returnValue; }