In my vb.net I have this code:
Private WithEvents RF As SiritController2._0.RFIDController
Public Sub StartReaders()
RF = New SiritController2._0.RFIDController(HP.RfIdAddress, HP.RfIdUserName, HP.RfIdPassword, HP.RfIdAntena)
EndSub
In my c# I have this code:
private RFIDController reader;
private void Start()
{
reader = new RFIDController(HP.RfIdAddress, "HP.RfIdUserName", "HP.RfIdPassword", HP.RfIdAntena);
reader.DetectRFID += Reader_DetectRFID;
}
These 2 codes are calling the same class on the same constructor
public RFIDController(string HostIP, string userName, string userPass, string AntennaNoPort = "1")
{
RFIDController.__ENCAddToList((object) this);
this.SvcTimerInterval = 45000;
this.ReaderTimeOut = 1000;
this.RaiseEventDelay = 0;
this._lastReadRFTagNumber = string.Empty;
this._LRRFT = new RFIDController.LastReadRFTagNumber();
try
{
if (string.IsNullOrEmpty(userName) | string.IsNullOrEmpty(userPass))
throw new Exception("Reader username or password cannot be empty.");
this.IPAddress = HostIP;
this.ReaderUser = userName;
this.ReaderPW = userPass;
this.AntennaNo = AntennaNoPort;
this.Connect();
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
throw new Exception("Error occured while instantiating controller : " + ex.InnerException.ToString());
}
}
Why is it that I get an error of
"Object reference not set to an instance"
in my C# code but not in my VB code? Upon inspection, I can see my parameters get filled.