System.ArgumentException:'参数无效。在C#中

时间:2019-10-27 08:13:41

标签: c# winforms exception

我遇到了问题,但我不知道为什么。

namespace RCSv1._0
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm()); // The exception throws here
        }
    }
}


该错误在程序开始运行时不会发生,在激活4个这些事件中的1个时会发生,并且异常是随机发生的(可能在4个事件中的任何一个中发生)

        public MainForm()
        {
            InitializeComponent();

            homeInputPanel = new HomeInputPanel(pnlHomeInput);
            nuclideInputPanel = new NuclideInputPanel(pnlNuclideInput);
            modelsInputPanel = new ModelsInputPanel(pnlModelsInput);
            kineticsInputPanel = new KineticsInputPanel(pnlKineticsInput);
            doseOutputPanel = new DoseOutputPanel(pnlDoseOutput);
            pnlHomeInput.BringToFront();
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void BtnNuclideInput_Click(object sender, EventArgs e)
        {
            DrawColourMouseHoverMenuButton(btnNuclideInput);
            pnlNuclideInput.BringToFront();
        }

        private void BtnModelsInput_Click(object sender, EventArgs e)
        {
            DrawColourMouseHoverMenuButton(btnModelsInput);
            pnlModelsInput.BringToFront();
        }

        private void BtnKineticsInput_Click(object sender, EventArgs e)
        {
            DrawColourMouseHoverMenuButton(btnKineticsInput);
            pnlKineticsInput.BringToFront();
        }

        private void BtnHomeInput_Click(object sender, EventArgs e)
        {
            DrawColourMouseHoverMenuButton(btnHomeInput);
            pnlHomeInput.BringToFront();
            UserData.HumanAge = modelsInputPanel.ReturnHumanAgeOption();
        }

        public void DrawColourMouseHoverMenuButton(BunifuThinButton2 btn)
        {
            btnNuclideInput.IdleFillColor = Color.White;
            btnNuclideInput.IdleForecolor = Color.SeaGreen;
            btnModelsInput.IdleFillColor = Color.White;
            btnModelsInput.IdleForecolor = Color.SeaGreen;
            btnKineticsInput.IdleFillColor = Color.White;
            btnKineticsInput.IdleForecolor = Color.SeaGreen;
            btnDose.IdleFillColor = Color.White;
            btnDose.IdleForecolor = Color.SeaGreen;
            btnHomeInput.IdleFillColor = Color.White;
            btnHomeInput.IdleForecolor = Color.SeaGreen;
            btn.IdleFillColor = Color.SeaGreen;
            btn.IdleForecolor = Color.White;
        }

我不知道为什么会发生此错误。有人可以解释吗?

调用堆栈是RCSv1.0.exe!RCSv1._0.Program.Main()第19行     在D:\ NHHSchool \ RCSProgram \ RCSProgram \ RCSv1.0 \ Program.cs(19)

0 个答案:

没有答案