×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Cannot perform runtime binding on a null reference

Cannot perform runtime binding on a null reference

Cannot perform runtime binding on a null reference

(OP)
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


contd.

I am not sure if this is the wrong forum but if it is please let me know.  If it isn't here is an update:

I built a seperate application, this time a desktop C# windows form application.  I copied the code and ran it from that application and it worked.  The things that are different are:
 one is a service and one is a desktop app
 one runs under a service user account the other runs under the user account

The desktop works but the service doesn't.

Other things to note, though these may appear to be obvious to this group, is that after running
            EXTRA.ExtraSystem system = new EXTRA.ExtraSystem();
            EXTRA.ExtraSessions sessions = system.Sessions;

Two processes appear and inherit the callers security credentials, ie if the windows form app is executed by me the two new processes also spawned are under my security context as well.

These are:

AccMgr32
AccSmngr

These appear to manage attachmates session and application processes for emulation and connectivity to the mainframe.  One of the thoughts I am playing with is that these credentials may not have access to something required.  But I have confirmed that the security credentials would not have changed recently.

It does appear that I can reproduce the same error, though may not be the error actually in question by running the desktop application under different user accounts.  Ie first run it under my account and then subsequently run it under a different account and when the above two processes are running under a different account we get this error.

Thoughts?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close