Search code examples
referencedelphi-prismgui-designer

Object reference not set to an instance of an object


One thing I can definitely say about Delphi Prism is that it is flaky. If you make some changes and worked through your program one line at a time, somehow you always come across some kind of errors, even though your program compiles and runs.

All I did was add menu-items and added its events and now Delphi Prism compiler is complaining that "Object reference not set to an instance of an object" every time when I try to open the main form designer. I don't even get to see the main winform for my program but the following information. I thought, if I remove the changes the error will go away, but it doesn't. It seems to be stuck on it.

Object reference not set to an instance of an object.     

Instances of this error (1)  

1.   Hide Call Stack 

at A.d..ctor(String A, j a)
at A.E..ctor(String A, j a)
at A.b.A(F A)
at A.b.Parse(TextReader A)
at System.CodeDom.Compiler.CodeDomProvider.Parse(TextReader codeStream)
at Microsoft.VisualStudio.Shell.Design.Serialization.CodeDom.CodeDomDocDataAdapter.get_CompileUnit()
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)  

The error message doesn't indicate where or what part of the program or code it is having problem, but the program compiles and runs flawlessly. Only thing is now I can't open the main window form designer to make any changes to the main winform.

What is the problem? Please, help me!!!

To be more precise: I was trying to add a user defined dialog window, but in the process I ended up adding a new item of UserControl Window as one of the item in the project treeview without including resx. From then on my main window form won't open in the designer and it displays the error that is posted above. However, everything compiles and runs. As stated before, I can't open the main window form in the designer.

Here is the main.designer.pas code:

namespace MillenniaMono.main;

interface

uses
  System.Windows.Forms,
  System.Drawing;

type
  MainForm = partial class
  {$REGION Windows Form Designer generated fields}
  private
    UnitBtn: System.Windows.Forms.Button;
    SignalBtn: System.Windows.Forms.Button;
    ControlBtn: System.Windows.Forms.Button;
    PIDBtn: System.Windows.Forms.Button;
    LoggingBtn: System.Windows.Forms.Button;
    SystemBtn: System.Windows.Forms.Button;
    LoginBtn: System.Windows.Forms.Button;
    ScanBtn: System.Windows.Forms.Button;
    ShutdownBtn: System.Windows.Forms.Button;
    HideBtn: System.Windows.Forms.Button;
    CommBtn: System.Windows.Forms.Button;
    button5: System.Windows.Forms.Button;
    button4: System.Windows.Forms.Button;
    button2: System.Windows.Forms.Button;
    button1: System.Windows.Forms.Button;
    listBox1: System.Windows.Forms.ListBox;
    //components: System.ComponentModel.IContainer;
    AlarmsBtn: System.Windows.Forms.Button;
    DataViewBtn: System.Windows.Forms.Button;
    MagiKalBtn: System.Windows.Forms.Button;
    HelpBtn: System.Windows.Forms.Button;
    OptionBtn: System.Windows.Forms.Button;
    halfBtn: System.Windows.Forms.Button;
    AlarmViewBtn: System.Windows.Forms.Button;
    method InitializeComponent;
  {$ENDREGION}
  end;

implementation

{$REGION Windows Form Designer generated code}
method MainForm.InitializeComponent;
begin
  var resources: System.ComponentModel.ComponentResourceManager := new System.ComponentModel.ComponentResourceManager(typeOf(MainForm));
  self.HideBtn := new System.Windows.Forms.Button();
  self.ShutdownBtn := new System.Windows.Forms.Button();
  self.AlarmViewBtn := new System.Windows.Forms.Button();
  self.ScanBtn := new System.Windows.Forms.Button();
  self.halfBtn := new System.Windows.Forms.Button();
  self.OptionBtn := new System.Windows.Forms.Button();
  self.HelpBtn := new System.Windows.Forms.Button();
  self.LoginBtn := new System.Windows.Forms.Button();
  self.MagiKalBtn := new System.Windows.Forms.Button();
  self.DataViewBtn := new System.Windows.Forms.Button();
  self.SystemBtn := new System.Windows.Forms.Button();
  self.LoggingBtn := new System.Windows.Forms.Button();
  self.PIDBtn := new System.Windows.Forms.Button();
  self.ControlBtn := new System.Windows.Forms.Button();
  self.AlarmsBtn := new System.Windows.Forms.Button();
  self.SignalBtn := new System.Windows.Forms.Button();
  self.UnitBtn := new System.Windows.Forms.Button();
  self.CommBtn := new System.Windows.Forms.Button();
  self.button2 := new System.Windows.Forms.Button();
  self.button4 := new System.Windows.Forms.Button();
  self.button5 := new System.Windows.Forms.Button();
  self.button1 := new System.Windows.Forms.Button();
  self.listBox1 := new System.Windows.Forms.ListBox();
  self.SuspendLayout();
  // 
  // HideBtn
  // 
  self.HideBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.HideBtn.Location := new System.Drawing.Point(97, 518);
  self.HideBtn.Name := 'HideBtn';
  self.HideBtn.Size := new System.Drawing.Size(52, 24);
  self.HideBtn.TabIndex := 36;
  self.HideBtn.Text := 'Hide';
  self.HideBtn.UseVisualStyleBackColor := true;
  // 
  // ShutdownBtn
  // 
  self.ShutdownBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.ShutdownBtn.Location := new System.Drawing.Point(12, 518);
  self.ShutdownBtn.Name := 'ShutdownBtn';
  self.ShutdownBtn.Size := new System.Drawing.Size(79, 24);
  self.ShutdownBtn.TabIndex := 35;
  self.ShutdownBtn.Text := 'Shutdown';
  self.ShutdownBtn.UseVisualStyleBackColor := true;
  self.ShutdownBtn.Click += new System.EventHandler(@self.ShutdownBtn_Click);
  // 
  // AlarmViewBtn
  // 
  self.AlarmViewBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.AlarmViewBtn.Location := new System.Drawing.Point(12, 449);
  self.AlarmViewBtn.Name := 'AlarmViewBtn';
  self.AlarmViewBtn.Size := new System.Drawing.Size(137, 24);
  self.AlarmViewBtn.TabIndex := 34;
  self.AlarmViewBtn.Text := 'Alarm Viewer';
  self.AlarmViewBtn.UseVisualStyleBackColor := true;
  // 
  // ScanBtn
  // 
  self.ScanBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.ScanBtn.Location := new System.Drawing.Point(12, 488);
  self.ScanBtn.Name := 'ScanBtn';
  self.ScanBtn.Size := new System.Drawing.Size(137, 24);
  self.ScanBtn.TabIndex := 33;
  self.ScanBtn.Text := 'Start Scanning';
  self.ScanBtn.UseVisualStyleBackColor := true;
  // 
  // halfBtn
  // 
  self.halfBtn.Location := new System.Drawing.Point(87, 233);
  self.halfBtn.Name := 'halfBtn';
  self.halfBtn.Size := new System.Drawing.Size(19, 23);
  self.halfBtn.TabIndex := 32;
  self.halfBtn.Text := '<';
  self.halfBtn.UseVisualStyleBackColor := true;
  // 
  // OptionBtn
  // 
  self.OptionBtn.Location := new System.Drawing.Point(12, 233);
  self.OptionBtn.Name := 'OptionBtn';
  self.OptionBtn.Size := new System.Drawing.Size(62, 23);
  self.OptionBtn.TabIndex := 31;
  self.OptionBtn.Text := 'Option';
  self.OptionBtn.UseVisualStyleBackColor := true;
  // 
  // HelpBtn
  // 
  self.HelpBtn.Location := new System.Drawing.Point(120, 233);
  self.HelpBtn.Name := 'HelpBtn';
  self.HelpBtn.Size := new System.Drawing.Size(19, 23);
  self.HelpBtn.TabIndex := 30;
  self.HelpBtn.Text := '?';
  self.HelpBtn.UseVisualStyleBackColor := true;
  // 
  // LoginBtn
  // 
  self.LoginBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.LoginBtn.Location := new System.Drawing.Point(12, 204);
  self.LoginBtn.Name := 'LoginBtn';
  self.LoginBtn.Size := new System.Drawing.Size(137, 24);
  self.LoginBtn.TabIndex := 29;
  self.LoginBtn.Text := 'Login';
  self.LoginBtn.UseVisualStyleBackColor := true;
  self.LoginBtn.Click += new System.EventHandler(@self.LoginBtn_Click);
  // 
  // MagiKalBtn
  // 
  self.MagiKalBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.MagiKalBtn.Location := new System.Drawing.Point(12, 389);
  self.MagiKalBtn.Name := 'MagiKalBtn';
  self.MagiKalBtn.Size := new System.Drawing.Size(137, 24);
  self.MagiKalBtn.TabIndex := 28;
  self.MagiKalBtn.Text := 'MagiKal';
  self.MagiKalBtn.UseVisualStyleBackColor := true;
  // 
  // DataViewBtn
  // 
  self.DataViewBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.DataViewBtn.Location := new System.Drawing.Point(12, 419);
  self.DataViewBtn.Name := 'DataViewBtn';
  self.DataViewBtn.Size := new System.Drawing.Size(137, 24);
  self.DataViewBtn.TabIndex := 27;
  self.DataViewBtn.Text := 'Data Viewer';
  self.DataViewBtn.UseVisualStyleBackColor := true;
  // 
  // SystemBtn
  // 
  self.SystemBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.SystemBtn.Location := new System.Drawing.Point(80, 349);
  self.SystemBtn.Name := 'SystemBtn';
  self.SystemBtn.Size := new System.Drawing.Size(69, 24);
  self.SystemBtn.TabIndex := 26;
  self.SystemBtn.Text := 'System';
  self.SystemBtn.UseVisualStyleBackColor := true;
  // 
  // LoggingBtn
  // 
  self.LoggingBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.LoggingBtn.Location := new System.Drawing.Point(80, 320);
  self.LoggingBtn.Name := 'LoggingBtn';
  self.LoggingBtn.Size := new System.Drawing.Size(69, 24);
  self.LoggingBtn.TabIndex := 24;
  self.LoggingBtn.Text := 'Logging';
  self.LoggingBtn.UseVisualStyleBackColor := true;
  // 
  // PIDBtn
  // 
  self.PIDBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.PIDBtn.Location := new System.Drawing.Point(12, 320);
  self.PIDBtn.Name := 'PIDBtn';
  self.PIDBtn.Size := new System.Drawing.Size(69, 23);
  self.PIDBtn.TabIndex := 23;
  self.PIDBtn.Text := 'PID';
  self.PIDBtn.UseVisualStyleBackColor := true;
  // 
  // ControlBtn
  // 
  self.ControlBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.ControlBtn.Location := new System.Drawing.Point(12, 291);
  self.ControlBtn.Name := 'ControlBtn';
  self.ControlBtn.Size := new System.Drawing.Size(70, 24);
  self.ControlBtn.TabIndex := 22;
  self.ControlBtn.Text := 'Control';
  self.ControlBtn.UseVisualStyleBackColor := true;
  // 
  // AlarmsBtn
  // 
  self.AlarmsBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.AlarmsBtn.Location := new System.Drawing.Point(80, 291);
  self.AlarmsBtn.Name := 'AlarmsBtn';
  self.AlarmsBtn.Size := new System.Drawing.Size(69, 24);
  self.AlarmsBtn.TabIndex := 21;
  self.AlarmsBtn.Text := 'Alarms';
  self.AlarmsBtn.UseVisualStyleBackColor := true;
  // 
  // SignalBtn
  // 
  self.SignalBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.SignalBtn.Location := new System.Drawing.Point(80, 262);
  self.SignalBtn.Name := 'SignalBtn';
  self.SignalBtn.Size := new System.Drawing.Size(69, 24);
  self.SignalBtn.TabIndex := 20;
  self.SignalBtn.Text := 'Signals';
  self.SignalBtn.UseVisualStyleBackColor := true;
  self.SignalBtn.Click += new System.EventHandler(@self.SignalBtn_Click);
  // 
  // UnitBtn
  // 
  self.UnitBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.UnitBtn.Location := new System.Drawing.Point(12, 262);
  self.UnitBtn.Name := 'UnitBtn';
  self.UnitBtn.Size := new System.Drawing.Size(69, 24);
  self.UnitBtn.TabIndex := 19;
  self.UnitBtn.Text := 'Units';
  self.UnitBtn.UseVisualStyleBackColor := true;
  self.UnitBtn.Click += new System.EventHandler(@self.UnitBtn_Click);
  // 
  // CommBtn
  // 
  self.CommBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
  self.CommBtn.Location := new System.Drawing.Point(12, 349);
  self.CommBtn.Name := 'CommBtn';
  self.CommBtn.Size := new System.Drawing.Size(69, 24);
  self.CommBtn.TabIndex := 25;
  self.CommBtn.Text := 'Comm';
  self.CommBtn.UseVisualStyleBackColor := true;
  self.CommBtn.Click += new System.EventHandler(@self.CommBtn_Click);
  // 
  // button2
  // 
  self.button2.Location := new System.Drawing.Point(37, 162);
  self.button2.Name := 'button2';
  self.button2.Size := new System.Drawing.Size(19, 23);
  self.button2.TabIndex := 38;
  self.button2.Text := 'button2';
  self.button2.UseVisualStyleBackColor := true;
  self.button2.Click += new System.EventHandler(@self.button2_Click);
  // 
  // button4
  // 
  self.button4.Location := new System.Drawing.Point(62, 162);
  self.button4.Name := 'button4';
  self.button4.Size := new System.Drawing.Size(19, 23);
  self.button4.TabIndex := 39;
  self.button4.Text := 'button4';
  self.button4.UseVisualStyleBackColor := true;
  self.button4.Click += new System.EventHandler(@self.button4_Click);
  // 
  // button5
  // 
  self.button5.Location := new System.Drawing.Point(87, 162);
  self.button5.Name := 'button5';
  self.button5.Size := new System.Drawing.Size(19, 23);
  self.button5.TabIndex := 40;
  self.button5.Text := 'button5';
  self.button5.UseVisualStyleBackColor := true;
  self.button5.Click += new System.EventHandler(@self.button5_Click);
  // 
  // button1
  // 
  self.button1.Location := new System.Drawing.Point(12, 162);
  self.button1.Name := 'button1';
  self.button1.Size := new System.Drawing.Size(19, 23);
  self.button1.TabIndex := 41;
  self.button1.Text := 'button1';
  self.button1.UseVisualStyleBackColor := true;
  self.button1.Click += new System.EventHandler(@self.button1_Click);
  // 
  // listBox1
  // 
  self.listBox1.Anchor := (((System.Windows.Forms.AnchorStyles.Top or System.Windows.Forms.AnchorStyles.Left) 
        or System.Windows.Forms.AnchorStyles.Right) as System.Windows.Forms.AnchorStyles);
  self.listBox1.FormattingEnabled := true;
  self.listBox1.Location := new System.Drawing.Point(10, 12);
  self.listBox1.Name := 'listBox1';
  self.listBox1.Size := new System.Drawing.Size(136, 95);
  self.listBox1.TabIndex := 42;
  // 
  // MainForm
  // 
  self.ClientSize := new System.Drawing.Size(158, 554);
  self.Controls.Add(self.listBox1);
  self.Controls.Add(self.button1);
  self.Controls.Add(self.button5);
  self.Controls.Add(self.button4);
  self.Controls.Add(self.button2);
  self.Controls.Add(self.HideBtn);
  self.Controls.Add(self.ShutdownBtn);
  self.Controls.Add(self.AlarmViewBtn);
  self.Controls.Add(self.ScanBtn);
  self.Controls.Add(self.halfBtn);
  self.Controls.Add(self.OptionBtn);
  self.Controls.Add(self.HelpBtn);
  self.Controls.Add(self.LoginBtn);
  self.Controls.Add(self.MagiKalBtn);
  self.Controls.Add(self.DataViewBtn);
  self.Controls.Add(self.SystemBtn);
  self.Controls.Add(self.CommBtn);
  self.Controls.Add(self.LoggingBtn);
  self.Controls.Add(self.PIDBtn);
  self.Controls.Add(self.ControlBtn);
  self.Controls.Add(self.AlarmsBtn);
  self.Controls.Add(self.SignalBtn);
  self.Controls.Add(self.UnitBtn);
  self.DoubleBuffered := true;
  self.Icon := (resources.GetObject('$this.Icon') as System.Drawing.Icon);
  self.MaximizeBox := false;
  self.MinimizeBox := false;
  self.Name := 'MainForm';
  self.Text := 'Millennia-FT';
  self.Load += new System.EventHandler(@self.MainForm_Load);
  self.ResumeLayout(false);
end;
{$ENDREGION}

end.

Here is the Main.pas Form code:

namespace MillenniaMono.Main;

interface

uses
  System.Drawing,
  System.Collections,
  System.Collections.Generic,
  System.Windows.Forms,
  System.ComponentModel,
  System.Threading,
  System.IO.Ports,
  MillenniaMono.*;

type
  /// <summary>
  /// Summary description for MainForm.
  /// </summary>
  MainForm = partial class(System.Windows.Forms.Form)
  private
    method SignalBtn_Click(sender: System.Object; e: System.EventArgs);
    method CommBtn_Click(sender: System.Object; e: System.EventArgs);
    method button1_Click(sender: System.Object; e: System.EventArgs);
    method button2_Click(sender: System.Object; e: System.EventArgs);
    method button4_Click(sender: System.Object; e: System.EventArgs);
    method button5_Click(sender: System.Object; e: System.EventArgs);
    method MainForm_Load(sender: System.Object; e: System.EventArgs); 
    method ShutdownBtn_Click(sender: System.Object; e: System.EventArgs);
    method MySerialData(sender: System.Object; e:SerialDataReceivedEventArgs);
    method LoginBtn_Click(sender: System.Object; e: System.EventArgs);
    method UnitBtn_Click(sender: System.Object; e: System.EventArgs);
  protected
    method Dispose(disposing: Boolean); override;
  public
    RX:Array[0..5] of byte;
    TX:Array[0..6] of byte;
    serialPort1:System.IO.Ports.SerialPort;
    thr:Thread;
    stoploop:Boolean;
    mcommand:Byte;
    thechannel:Integer;
    fr : UnitForm;
    constructor;
    method FillTable;
    method mythread;
  end;

implementation

{$REGION Construction and Disposition}

constructor MainForm;
begin
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent();

  mcommand:=$AA;
  thechannel:=$01;
  stoploop:=false;
  thr:=nil;
  fr := new UnitForm;
  //
  // TODO: Add any constructor code after InitializeComponent call

  //
end;

method MainForm.Dispose(disposing: Boolean);
begin
  if disposing then begin
    //if assigned(components) then
    //  components.Dispose();

    //
    // TODO: Add custom disposition code here
    //

    if not(SerialPort1=nil) then
        SerialPort1.Close;

    stoploop:=true;

    if not(thr=nil) then
        thr.Abort;
  end;
  inherited Dispose(disposing);
end;
{$ENDREGION}

method MainForm.FillTable;
begin

end;

method MainForm.MySerialData(sender: Object; e: SerialDataReceivedEventArgs);
begin
    if not SerialPort1.IsOpen then Exit;   

    try
        SerialPort1.Read(RX,0,5);
        fr.UpdateGrid(RX);
    except on ex: exception do 
    begin
        exit;
    end;
    end;
end;

procedure MainForm.mythread;
var x,y:Integer;
begin
    while true do
    begin
        TX[0]:=$FF;
        TX[1]:=$01;
        TX[2]:=$01;
        TX[3]:=thechannel;
        TX[4]:=mcommand;
        TX[5]:=(TX[2] xor TX[3] xor TX[4]);

        SerialPort1.RtsEnable:=true;
        SerialPort1.DiscardInBuffer;
        SerialPort1.DiscardOutBuffer;
        SerialPort1.Write(TX,0,6);
        while SerialPort1.BytesToWrite>0 do;
        y:=0;
        for x:=0 to 700000 do
        begin
            y:=y+(x+10);
        end;
        SerialPort1.RtsEnable:=false;

        Thread.Sleep(50);

        if (stoploop) then
            break;
    end;
end;

method MainForm.SignalBtn_Click(sender: System.Object; e: System.EventArgs);
begin

end;

method MainForm.CommBtn_Click(sender: System.Object; e: System.EventArgs);
begin  

    if SerialPort1 = nil then
        SerialPort1 := new System.Io.Ports.SerialPort();
    SerialPort1.Close;

    SerialPort1 := new System.Io.Ports.SerialPort();
    SerialPort1.BaudRate:=19200;
    SerialPort1.DataBits:=8;
    SerialPort1.Parity:=System.IO.Ports.Parity.Even;
    SerialPort1.PortName:='COM1';//'/dev/ttyS0';
    SerialPort1.ReadBufferSize:=3000;
    SerialPort1.ReadTimeout:=1000;
    SerialPort1.StopBits:=System.IO.Ports.StopBits.One;
    SerialPort1.WriteTimeout:=1000;
    SerialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(@MySerialData);
    SerialPort1.Open;

    thr:= new Thread(@mythread);
    thr.Start;
end;

method MainForm.button1_Click(sender: System.Object; e: System.EventArgs);
begin
    thechannel:=$04;
    mcommand:=$A1;
end;

method MainForm.button2_Click(sender: System.Object; e: System.EventArgs);
begin
  thechannel:=$04;
  mcommand:=$A2;
end;

method MainForm.button4_Click(sender: System.Object; e: System.EventArgs);
begin
  thechannel:=$04;
  mcommand:=$A4;
end;

method MainForm.button5_Click(sender: System.Object; e: System.EventArgs);
begin
  thechannel:=$04;
  mcommand:=$A8;
end;

method MainForm.MainForm_Load(sender: System.Object; e: System.EventArgs);
begin

end;

method MainForm.ShutdownBtn_Click(sender: System.Object; e: System.EventArgs);
begin
  stoploop:=true;
  close;
end;

method MainForm.LoginBtn_Click(sender: System.Object; e: System.EventArgs);
begin

end;

method MainForm.UnitBtn_Click(sender: System.Object; e: System.EventArgs);
begin
  fr.Show;  
end;

end.

Solution

  • I solved it. Well, it is really a workaround. Since the compiler didn't give me enough information to track down the error, I recreated the window form with all the same settings and deleted the other form. Now it is working.