I get the message "Object reference not set to an instance of an object." on this line of code:
LaneControllerLane(this, EventArgs.Empty);
This is the whole program:
MainForm
public static event EventHandler LaneControllerDevice;
public static event EventHandler LaneControllerLane;
internal void LaneMessage(string message)
{
CommonEntitiesForTollApps.LANE = message.Split('|')[0];
CommonEntitiesForTollApps.DEVICE = message.Split('|')[1];
pnlForControl.BeginInvoke(new Action(() =>
{
LaneControllerLane(this, EventArgs.Empty);
}));
}
ControlForm
private void ctrlLane_Load(object sender, EventArgs e)
{
MainForm.LaneControllerDevice += new EventHandler(CheckSignal);
MainForm.LaneControllerLane += new EventHandler(CheckLaneOperation);
}
private void CheckLaneOperation(object sender, EventArgs e)
{
if(CommonEntitiesForTollApps.LANE == this.LaneName)
{
switch (DEVICE)
{
case "Scanner":
lblScanner.Text = "1";
break;
case "Printer":
lblPrinter.Text = "1";
break;
case "RFID":
lblTransactionType.Text = CommonEntitiesForTollApps.TRANSACTION_TYPE;
break;
}
}
else
{
return;
}
}
Can you please point out what I am doing wrong? Thank you.