Background:
This code is ran in a service. For every user this code is called to reset their password for this application. This is an SSO environment, but the error is reproducable outside the environment.
The error is that occasionally, I get a Cannot perform runtime binding on a null reference. I have checked that it isn't a data issue by doing this process manually. Also, I am new to this forum so if I am breaking some etiquette don't hesitate to scold me .
The code:
EXTRA.ExtraSystem system = new EXTRA.ExtraSystem();
EXTRA.ExtraSessions sessions = system.Sessions;
var session = sessions.Open("X.adp");
try
{
Thread.Sleep(2000);
*I GET THE NULL REFERENCE ERROR BELOW THIS LINE
var status = session.Screen.OIA.Xstatus;
session.Visible = true;
LOG *I GET THE NULL REFERENCE ERROR BEFORE THIS LINE
Thread.Sleep(500);
session.Screen.Sendkeys("<Clear>");
session.Screen.Sendkeys("/rcl<Enter>");
session.Screen.WaitHostQuiet(1000);
Thread.Sleep(1000);
*POPULATING SCREEN*
*Gets Screen Response and determins if successful
string screenResponse = session.Screen.GetString(23, 1, 70);
session.Screen.Sendkeys("<Clear>");
session.Screen.WaitHostQuiet(1000);
session.Screen.Sendkeys("/rcl<Enter>"); //logout|disconnect
session.Screen.WaitHostQuiet(3000);
Thread.Sleep(1000);
}
catch (Exception ex)
{
*Handle Error*
}
finally
{
session.Visible = false;
Marshal.FinalReleaseComObject(sessions);
Marshal.FinalReleaseComObject(system);
Thread.Sleep(500);
}
Technology:
C#
Attachmate EXTRA! 7.1 Object Library
My questions:
1.) Being that this happens not often, I am thinking this may due with me accessing some variable when it isn't ready yet. Does anyone see anything that may be wrong from that perspective.
2.) What is the proper way to marhsall these objects from life to death? Anything else I maybe missing here?
3.) How should I properly treat var status = session.Screen.OIA.Xstatus? I have noticed in some forum entries that this is encased in a loop waiting for the value to change to 0? Is this expected or normal behavior? I have also noticed many, maybe more so entires where this value is completely ignored.
4.) Any other tips or suggestions is helpful. Thanks
This code is ran in a service. For every user this code is called to reset their password for this application. This is an SSO environment, but the error is reproducable outside the environment.
The error is that occasionally, I get a Cannot perform runtime binding on a null reference. I have checked that it isn't a data issue by doing this process manually. Also, I am new to this forum so if I am breaking some etiquette don't hesitate to scold me .
The code:
EXTRA.ExtraSystem system = new EXTRA.ExtraSystem();
EXTRA.ExtraSessions sessions = system.Sessions;
var session = sessions.Open("X.adp");
try
{
Thread.Sleep(2000);
*I GET THE NULL REFERENCE ERROR BELOW THIS LINE
var status = session.Screen.OIA.Xstatus;
session.Visible = true;
LOG *I GET THE NULL REFERENCE ERROR BEFORE THIS LINE
Thread.Sleep(500);
session.Screen.Sendkeys("<Clear>");
session.Screen.Sendkeys("/rcl<Enter>");
session.Screen.WaitHostQuiet(1000);
Thread.Sleep(1000);
*POPULATING SCREEN*
*Gets Screen Response and determins if successful
string screenResponse = session.Screen.GetString(23, 1, 70);
session.Screen.Sendkeys("<Clear>");
session.Screen.WaitHostQuiet(1000);
session.Screen.Sendkeys("/rcl<Enter>"); //logout|disconnect
session.Screen.WaitHostQuiet(3000);
Thread.Sleep(1000);
}
catch (Exception ex)
{
*Handle Error*
}
finally
{
session.Visible = false;
Marshal.FinalReleaseComObject(sessions);
Marshal.FinalReleaseComObject(system);
Thread.Sleep(500);
}
Technology:
C#
Attachmate EXTRA! 7.1 Object Library
My questions:
1.) Being that this happens not often, I am thinking this may due with me accessing some variable when it isn't ready yet. Does anyone see anything that may be wrong from that perspective.
2.) What is the proper way to marhsall these objects from life to death? Anything else I maybe missing here?
3.) How should I properly treat var status = session.Screen.OIA.Xstatus? I have noticed in some forum entries that this is encased in a loop waiting for the value to change to 0? Is this expected or normal behavior? I have also noticed many, maybe more so entires where this value is completely ignored.
4.) Any other tips or suggestions is helpful. Thanks