NullReferenceException

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
dthomas
Posts: 14
Joined: Tue Jun 11, 2019 6:06 pm

NullReferenceException

Post by dthomas »

I have two instances where if I try to run the program on specific Screens the program throws a NullReferenceException on an Object - yet if I change to a different screen in IX Developer and run the code it works just fine.

The weird one is I am not sure why it is throwing this exception. In the first case it is a ScriptModule where I have created a Dictionary. In one of the functions I am trying to get the size of the Dictionary using Dictionary.Count. I assumed that this was due to a newly defined Dictionary with no entries causing this problem when the Count is called. The issue is from everything I read a newly defined Dictionary will give a count of 0 from the start.

The second is on another screen where I am checking to see if the user has entered some information on click of a button. The tag attached to the input field is a string and on button push I am checking if the string is Null or empty. Apparently checking to see if a tag is Null or empty seems to throw this exception.

dthomas
Posts: 14
Joined: Tue Jun 11, 2019 6:06 pm

Re: NullReferenceException

Post by dthomas »

I will leave this one alone for now. Is weird because it is throwing a NullException whe i am testing for Null so not sure why that is.

If I go to the tags tab I cab build and run and program works fine - so at this point assuming this is a weird glitch in the system. Then again now I am having a problem with the IEmailSenderService so maybe the glitch is a bit more than a glitch - will send another message for this one.

AMitchneck
Posts: 137
Joined: Mon Jun 11, 2012 2:10 pm

Re: NullReferenceException

Post by AMitchneck »

If I had to guess, you have something in your code like

if ( a.b.c == null ) ...

and the NullReferenceException is being thrown due to a.b being null.
Adam M.
Controls Engineer
FlexEnergy

Post Reply