Ошибка cs0120 как исправить

206
24 июня 2022, 07:30

Я не понимаю, как тут исправить данную ошибку:

case "-editor":
                    {
                        Application.Run(new Editor());
                        Editor.InitializeComponent();
                        break;
                    }

Куда обращаюсь:

public void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Editor));
        this.mainMenu = new System.Windows.Forms.MainMenu(this.components);
        this.City_Item = new System.Windows.Forms.MenuItem();
        this.New_Item = new System.Windows.Forms.MenuItem();
        this.Open_Item = new System.Windows.Forms.MenuItem();
        this.Save_Item = new System.Windows.Forms.MenuItem();
        this.SaveAs_Item = new System.Windows.Forms.MenuItem();
        this.SeparatorItem1 = new System.Windows.Forms.MenuItem();
        this.Refresh_All_TripStop_Lists_Item = new System.Windows.Forms.MenuItem();
        this.Check_Joints_Item = new System.Windows.Forms.MenuItem();
        this.Find_MinRadius_Item = new System.Windows.Forms.MenuItem();
        this.ComputeAllTime_Item = new System.Windows.Forms.MenuItem();
        this.Run_Item = new System.Windows.Forms.MenuItem();
        this.SeparatorItem2 = new System.Windows.Forms.MenuItem();
        this.Exit_Item = new System.Windows.Forms.MenuItem();
        this.statusBar = new System.Windows.Forms.StatusBar();
        this.Cursor_x_Status = new System.Windows.Forms.StatusBarPanel();
        this.Cursor_y_Status = new System.Windows.Forms.StatusBarPanel();
        this.SeparatorPanel1 = new System.Windows.Forms.StatusBarPanel();
        this.Coord_x1_Status = new System.Windows.Forms.StatusBarPanel();
        this.Coord_y1_Status = new System.Windows.Forms.StatusBarPanel();
        this.Angle1_Status = new System.Windows.Forms.StatusBarPanel();
        this.SeparatorPanel2 = new System.Windows.Forms.StatusBarPanel();
        this.Coord_x2_Status = new System.Windows.Forms.StatusBarPanel();
        this.Coord_y2_Status = new System.Windows.Forms.StatusBarPanel();
        this.Angle2_Status = new System.Windows.Forms.StatusBarPanel();
        this.SeparatorPanel3 = new System.Windows.Forms.StatusBarPanel();
        this.Length_Status = new System.Windows.Forms.StatusBarPanel();
        this.Radius_Status = new System.Windows.Forms.StatusBarPanel();
        this.Angle_Status = new System.Windows.Forms.StatusBarPanel();
        this.Wide0_Status = new System.Windows.Forms.StatusBarPanel();
        this.Wide1_Status = new System.Windows.Forms.StatusBarPanel();
        this.Height0_Status = new System.Windows.Forms.StatusBarPanel();
        this.Height1_Status = new System.Windows.Forms.StatusBarPanel();
        this.SeparatorPanel4 = new System.Windows.Forms.StatusBarPanel();
        this.Maschtab = new System.Windows.Forms.StatusBarPanel();
        this.SeparatorPanel5 = new System.Windows.Forms.StatusBarPanel();
        this.Ugol = new System.Windows.Forms.StatusBarPanel();
        this.toolBar = new System.Windows.Forms.ToolBar();
        this.New_Button = new System.Windows.Forms.ToolBarButton();
        this.Open_Button = new System.Windows.Forms.ToolBarButton();
        this.Save_Button = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton1 = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton2 = new System.Windows.Forms.ToolBarButton();
        this.Run_Button = new System.Windows.Forms.ToolBarButton();
        this.Play_Button = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton3 = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton4 = new System.Windows.Forms.ToolBarButton();
        this.ButtonUndo = new System.Windows.Forms.ToolBarButton();
        this.Edit_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Button = new System.Windows.Forms.ToolBarButton();
        this.Troll_lines_Button = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton5 = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton6 = new System.Windows.Forms.ToolBarButton();
        this.Stops_Button = new System.Windows.Forms.ToolBarButton();
        this.Park_Button = new System.Windows.Forms.ToolBarButton();
        this.Route_Button = new System.Windows.Forms.ToolBarButton();
        this.Signals_Button = new System.Windows.Forms.ToolBarButton();
        this.Svetofor_Button = new System.Windows.Forms.ToolBarButton();
        this.Object_Button = new System.Windows.Forms.ToolBarButton();
        this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
        this.SeparatorButton8 = new System.Windows.Forms.ToolBarButton();
        this.Rail_Edit_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_Direct_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_Curve_Button = new System.Windows.Forms.ToolBarButton();
        this.Road_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_попутки_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_попутки1_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_попутки2_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_попутки3_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_встречки_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_встречки1_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_встречки2_Button = new System.Windows.Forms.ToolBarButton();
        this.Rail_Build_встречки3_Button = new System.Windows.Forms.ToolBarButton();
        this.Park_Edit_Button = new System.Windows.Forms.ToolBarButton();
        this.Park_In_Button = new System.Windows.Forms.ToolBarButton();
        this.Park_Out_Button = new System.Windows.Forms.ToolBarButton();
        this.Park_Rails_Button = new System.Windows.Forms.ToolBarButton();
        this.Troll_lines_Edit_Button = new System.Windows.Forms.ToolBarButton();
        this.Troll_lines_Draw_Button = new System.Windows.Forms.ToolBarButton();
        this.Troll_lines_Flag_Button = new System.Windows.Forms.ToolBarButton();
        this.imageList = new System.Windows.Forms.ImageList(this.components);
        this.renderPanel = new Engine.Controls.RenderPanel();
        this.object_panel = new System.Windows.Forms.Panel();
        this.Objects_Instance_Box = new System.Windows.Forms.ComboBox();
        this.Objects_Instance_label = new System.Windows.Forms.Label();
        this.Objects_EditLocation_Button = new System.Windows.Forms.Button();
        this.Objects_ShowLocation_Button = new System.Windows.Forms.Button();
        this.Objects_Location_label = new System.Windows.Forms.Label();
        this.Objects_Remove_Button = new System.Windows.Forms.Button();
        this.Objects_Add_Button = new System.Windows.Forms.Button();
        this.Objects_Box = new System.Windows.Forms.ComboBox();
        this.Objects_label = new System.Windows.Forms.Label();
        this.route_panel = new System.Windows.Forms.Panel();
        this.StopsButton = new System.Windows.Forms.Button();
        this.Route_TransportType_Box = new System.Windows.Forms.ComboBox();
        this.Route_TransportType_label = new System.Windows.Forms.Label();
        this.Route_ShowNarads_Box = new System.Windows.Forms.CheckBox();
        this.Route_Runs_ComputeTime_Button = new System.Windows.Forms.Button();
        this.Route_Runs_Time_Box = new Trancity.TimeBox();
        this.Route_Runs_ToParkIndex_UpDown = new System.Windows.Forms.NumericUpDown();
        this.Route_Runs_ToPark_Box = new System.Windows.Forms.CheckBox();
        this.Route_Runs_Park_Box = new System.Windows.Forms.CheckBox();
        this.Route_Runs_Time_label = new System.Windows.Forms.Label();
        this.Route_Runs_ToParkIndex_label = new System.Windows.Forms.Label();
        this.Route_Runs_label = new System.Windows.Forms.Label();
        this.Route_Name_label = new System.Windows.Forms.Label();
        this.Route_Name_Box = new System.Windows.Forms.TextBox();
        this.Route_Runs_Remove_Button = new System.Windows.Forms.Button();
        this.Route_Remove_Button = new System.Windows.Forms.Button();
        this.Route_Runs_Add_Button = new System.Windows.Forms.Button();
        this.Route_Add_Button = new System.Windows.Forms.Button();
        this.Route_ChangeName_Button = new System.Windows.Forms.Button();
        this.Route_label = new System.Windows.Forms.Label();
        this.Route_Runs_Box = new System.Windows.Forms.ComboBox();
        this.Route_Box = new System.Windows.Forms.ComboBox();
        this.svetofor_panel = new System.Windows.Forms.Panel();
        this.Svetofor_Model_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Model_label = new System.Windows.Forms.Label();
        this.Svetofor_Svetofor_ArrowRed_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Svetofor_ArrowYellow_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Svetofor_ArrowGreen_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Cycle_Box = new Trancity.TimeBox();
        this.Svetofor_OfGreen_Box = new Trancity.TimeBox();
        this.Svetofor_End_Box = new Trancity.TimeBox();
        this.Svetofor_ToGreen_Box = new Trancity.TimeBox();
        this.Svetofor_Begin_Box = new Trancity.TimeBox();
        this.Svetofor_Element_Location_label = new System.Windows.Forms.Label();
        this.Svetofor_Cycle_label = new System.Windows.Forms.Label();
        this.Svetofor_Green_label = new System.Windows.Forms.Label();
        this.Svetofor_Work_label = new System.Windows.Forms.Label();
        this.Svetofor_Remove_Button = new System.Windows.Forms.Button();
        this.Svetofor_Svetofor_ArrowRed_label = new System.Windows.Forms.Label();
        this.Svetofor_Svetofor_ArrowYellow_label = new System.Windows.Forms.Label();
        this.Svetofor_Svetofor_ArrowGreen_label = new System.Windows.Forms.Label();
        this.Svetofor_Element_label = new System.Windows.Forms.Label();
        this.Svetofor_Add_Button = new System.Windows.Forms.Button();
        this.Svetofor_Element_EditLocation_Button = new System.Windows.Forms.Button();
        this.Svetofor_Element_ShowLocation_Button = new System.Windows.Forms.Button();
        this.Svetofor_label = new System.Windows.Forms.Label();
        this.Svetofor_Element_Remove_Button = new System.Windows.Forms.Button();
        this.Svetofor_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Element_Box = new System.Windows.Forms.ComboBox();
        this.Svetofor_Signal_Add_Button = new System.Windows.Forms.Button();
        this.Svetofor_Svetofor_Add_Button = new System.Windows.Forms.Button();
        this.splines_panel = new System.Windows.Forms.Panel();
        this.Rail_Box_NumericBox = new Common.NumericBox();
        this.Spline_Select_mode_Box = new System.Windows.Forms.CheckBox();
        this.Splines_Instance_Box = new System.Windows.Forms.ComboBox();
        this.Splines_Instance_label = new System.Windows.Forms.Label();
        this.Splines_ShowLocation_Button = new System.Windows.Forms.Button();
        this.Rail_Box_dist_Label = new System.Windows.Forms.Label();
        this.Splines_Location_label = new System.Windows.Forms.Label();
        this.Splines_ChangeModel_Button = new System.Windows.Forms.Button();
        this.Splines_Remove_Button = new System.Windows.Forms.Button();
        this.Splines_Models_Box = new System.Windows.Forms.ComboBox();
        this.Splines_label = new System.Windows.Forms.Label();
        this.signals_panel = new System.Windows.Forms.Panel();
        this.Signals_Model_Box = new System.Windows.Forms.ComboBox();
        this.Signals_Model_label = new System.Windows.Forms.Label();
        this.Signals_Element_Minus_Box = new System.Windows.Forms.CheckBox();
        this.Signals_Bound_UpDown = new System.Windows.Forms.NumericUpDown();
        this.Signals_Element_Location_label = new System.Windows.Forms.Label();
        this.Signals_Bound_label = new System.Windows.Forms.Label();
        this.Signals_Remove_Button = new System.Windows.Forms.Button();
        this.Signals_Element_label = new System.Windows.Forms.Label();
        this.Signals_Add_Button = new System.Windows.Forms.Button();
        this.Signals_Element_EditLocation_Button = new System.Windows.Forms.Button();
        this.Signals_Element_ShowLocation_Button = new System.Windows.Forms.Button();
        this.Signals_label = new System.Windows.Forms.Label();
        this.Signals_Element_Remove_Button = new System.Windows.Forms.Button();
        this.Signals_Box = new System.Windows.Forms.ComboBox();
        this.Signals_Element_Box = new System.Windows.Forms.ComboBox();
        this.Signals_Element_AddSignal_Button = new System.Windows.Forms.Button();
        this.Signals_Element_AddContact_Button = new System.Windows.Forms.Button();
        this.stops_panel = new System.Windows.Forms.Panel();
        this.Stops_Model_Box = new System.Windows.Forms.ComboBox();
        this.Stops_Model_label = new System.Windows.Forms.Label();
        this.TypeOfTransportBox = new System.Windows.Forms.GroupBox();
        this.BusBox = new System.Windows.Forms.CheckBox();
        this.TrolleybusBox = new System.Windows.Forms.CheckBox();
        this.TramwayBox = new System.Windows.Forms.CheckBox();
        this.Stops_Location_label = new System.Windows.Forms.Label();
        this.Stops_Name_label = new System.Windows.Forms.Label();
        this.Stops_Name_Box = new System.Windows.Forms.TextBox();
        this.Stops_Remove_Button = new System.Windows.Forms.Button();
        this.Stops_Add_Button = new System.Windows.Forms.Button();
        this.Stops_EditLocation_Button = new System.Windows.Forms.Button();
        this.Stops_ShowLocation_Button = new System.Windows.Forms.Button();
        this.Stops_ChangeName_Button = new System.Windows.Forms.Button();
        this.Stops_label = new System.Windows.Forms.Label();
        this.Stops_Box = new System.Windows.Forms.ComboBox();
        this.park_panel = new System.Windows.Forms.Panel();
        this.Park_Name_label = new System.Windows.Forms.Label();
        this.Park_Name_Box = new System.Windows.Forms.TextBox();
        this.Park_Remove_Button = new System.Windows.Forms.Button();
        this.Park_ChangeName_Button = new System.Windows.Forms.Button();
        this.Park_Add_Button = new System.Windows.Forms.Button();
        this.Park_label = new System.Windows.Forms.Label();
        this.Park_Box = new System.Windows.Forms.ComboBox();
        this.Refresh_Timer = new System.Windows.Forms.Timer(this.components);
        this.Sizable_Panel = new System.Windows.Forms.Panel();
        this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
        this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
        this.edit_panel = new System.Windows.Forms.Panel();
        this.narad_panel = new System.Windows.Forms.Panel();
        this.RollingStockBox = new System.Windows.Forms.ComboBox();
        this.Transport_label = new System.Windows.Forms.Label();
        this.Narad_Runs_Time2_Box = new Trancity.TimeBox();
        this.Narad_Runs_Time1_Box = new Trancity.TimeBox();
        this.Narad_Runs_Time2_label = new System.Windows.Forms.Label();
        this.Narad_Runs_Time1_label = new System.Windows.Forms.Label();
        this.Narad_Runs_label = new System.Windows.Forms.Label();
        this.Narad_Park_label = new System.Windows.Forms.Label();
        this.Narad_Runs_Run_label = new System.Windows.Forms.Label();
        this.Narad_Name_label = new System.Windows.Forms.Label();
        this.Narad_Name_Box = new System.Windows.Forms.TextBox();
        this.Narad_Runs_Remove_Button = new System.Windows.Forms.Button();
        this.Narad_Remove_Button = new System.Windows.Forms.Button();
        this.Narad_Runs_Add_Button = new System.Windows.Forms.Button();
        this.Narad_Add_Button = new System.Windows.Forms.Button();
        this.Narad_ChangeName_Button = new System.Windows.Forms.Button();
        this.Narad_label = new System.Windows.Forms.Label();
        this.Narad_Park_Box = new System.Windows.Forms.ComboBox();
        this.Narad_Runs_Run_Box = new System.Windows.Forms.ComboBox();
        this.Narad_Runs_Box = new System.Windows.Forms.ComboBox();
        this.Narad_Box = new System.Windows.Forms.ComboBox();
        ((System.ComponentModel.ISupportInitialize)(this.Cursor_x_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Cursor_y_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.SeparatorPanel1)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Coord_x1_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Coord_y1_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Angle1_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.SeparatorPanel2)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Coord_x2_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Coord_y2_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Angle2_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.SeparatorPanel3)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Length_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Radius_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Angle_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Wide0_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Wide1_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Height0_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Height1_Status)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.SeparatorPanel4)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Maschtab)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.SeparatorPanel5)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.Ugol)).BeginInit();
        this.object_panel.SuspendLayout();
        this.route_panel.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.Route_Runs_ToParkIndex_UpDown)).BeginInit();
        this.svetofor_panel.SuspendLayout();
        this.splines_panel.SuspendLayout();
        this.signals_panel.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.Signals_Bound_UpDown)).BeginInit();
        this.stops_panel.SuspendLayout();
        this.TypeOfTransportBox.SuspendLayout();
        this.park_panel.SuspendLayout();
        this.Sizable_Panel.SuspendLayout();
        this.narad_panel.SuspendLayout();
        this.SuspendLayout();

и

public Editor()
        {
            
            InitializeComponent();
        }
Answer 1
Editor.InitializeComponent();

Вам эта строка кода не нужна, она будет вызвана в конструкторе и второй раз вызывать не нужно. А ошибка возникает из-за того, что вы пытаетесь вызвать не статический метод, как статический, нужно передавать не название класса, общект у которого будет вызван этот метод. Например:

var editor = new Editor();
Application.Run(editor);
editor.InitializeComponent(); // тут уже компилятор ругаться не будет
READ ALSO
Как заставить выполняться длительный код по нажатию кнопки ASP.NET Core

Как заставить выполняться длительный код по нажатию кнопки ASP.NET Core

У меня есть код который должен работать 24/7 и есть сервер через который я должен его запускатьТо есть отправил запрос http://site

196
Двери работают странно

Двери работают странно

Делаю 2д платформер, захотел двериПо идее должно работать так - есть дверь, и у нее есть linkeddoor, при нажатии E пока в двери происходит телепортация...

229
c# Как скачать видео с vk.com?

c# Как скачать видео с vk.com?

С помощью VK API методом videoget получил ссылку на видео: Ссылка на видео

280