进程由于未处理的异常而终止-ArgumentOutOfRangeException

时间:2020-07-20 14:01:16

标签: c# .net winforms

我正在尝试运行Windows桌面应用程序,但出现以下错误:

Application: xxx.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentOutOfRangeException
   at System.Windows.Forms.ComboBox.Select(Int32, Int32)
   at xxx.win.shared.FancyComboBox.OnTextChanged(System.EventArgs)
   at xxx.win.shared.IDComboBox.OnTextChanged(System.EventArgs)
   at System.Windows.Forms.Control.set_Text(System.String)
   at System.Windows.Forms.ComboBox.set_Text(System.String)
   at System.Windows.Forms.ComboBox.UpdateText()
   at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32)
   at System.Windows.Forms.ComboBox.set_Text(System.String)
   at xxx.win.FrmSearch..ctor()
   at xxx.win.Startup.Main()

我删除了所有已安装的.NET框架实例,并安装了不同版本进行测试,结果仍然相同。

我运行了.NET版本检查器,这是当前安装的版本:

v3.0  3.0.30729.4926  SP2
v3.5  3.5.30729.4926  SP1
v4
  Client  4.8.03761
  Full  4.8.03761
v4.0
  Client  4.0.0.0

该应用程序的目标是.NETFramework版本4.6.2。因此,我应该在那方面受到保护。相同的应用程序可以在具有相同.NETFramework设置的另一台计算机上运行

2 个答案:

答案 0 :(得分:1)

您要处理的问题与.NET框架无关。

如果查看异常堆栈,则会看到FrmSearch表单的一个ComboBox引发了ArgumentOutOfRangeException。尝试找出哪个组合框引发了该异常,以及代码中的什么条件可能引发了这种异常。

如果您的ComboBox填充有外部数据(文件,数据库等),请确保一旦部署,数据源就可用于您的应用程序。

答案 1 :(得分:0)

@Jimi的评论是正确的,这不是框架问题。 foo <- function(x) { require(tidyverse) tibble(breaks, labels) %>% right_join(tibble(breaks=x, n=T)) %>% mutate(new = ifelse(!is.na(labels), labels, breaks)) %>% pull(new) } ggplot(data = type1, aes(x,y, group=1)) + geom_line() + scale_y_continuous(labels = foo) 通常与尝试访问或选择数组或列表范围之外的数组或列表中的值有关。

在您的堆栈跟踪中,它看起来像是来自组合框System.ArgumentOutOfRangeException

确保ComboBox中包含值,如果没有,则您的代码不会尝试选择一个值。

如果组合框中没有任何值,并且您正在执行类似System.Windows.Forms.ComboBox.Select(Int32, Int32)的操作,则会收到错误消息,因为 1 不在组合框的值范围内。

相关问题