<p>This is a segment of code from an app I've inherited, a user got a Yellow screen of death:</p>

<blockquote>
  <p>Object reference not set to an instance of an object</p>
</blockquote>

<p>on the line: </p>

<pre><code>bool l_Success ... 
</code></pre>

<p>Now I'm 95% sure the faulty argument is <code>ref l_Monitor</code> which is very weird considering the object is instantiated a few lines before. Anyone have a clue why it would happen? Note that I have seen the same issue pop up in other places in the code.</p>

<pre><code>IDMS.Monitor l_Monitor = new IDMS.Monitor();
l_Monitor.LogFile.Product_ID = "SE_WEB_APP";

if (m_PermType_RadioButtonList.SelectedIndex == -1) {
    l_Monitor.LogFile.Log(
        Nortel.IS.IDMS.LogFile.MessageTypes.ERROR,
        "No permission type selected"
        );
    return;
}
bool l_Success = SE.UI.Utilities.GetPermissionList(
    ref l_Monitor,
    ref m_CPermissions_ListBox,
    (int)this.ViewState["m_Account_Share_ID"],
    (m_PermFolders_DropDownList.Enabled)
        ? m_PermFolders_DropDownList.SelectedItem.Value
        : "-1",
    (SE.Types.PermissionType)m_PermType_RadioButtonList.SelectedIndex,
    (SE.Types.PermissionResource)m_PermResource_RadioButtonList.SelectedIndex);
</code></pre>

[{'answer_id': 55138, 'author': 'Darren Kopp', 'author_id': 77, 'author_profile': 'https://Stackoverflow.com/users/77', 'pm_score': 1, 'selected': False, 'text': "<p>You sure that one of the properties trying to be accessed on the l_Monitor instance isn't null?</p>\n"}, {'answer_id': 55144, 'author': 'Gishu', 'author_id': 1695, 'author_profile': 'https://Stackoverflow.com/users/1695', 'pm_score': 0, 'selected': False, 'text': '<p>Sprinkle in a few variables for all the property-queries on that (loooooongg) line temporarily. Run the debugger, Check values and Corner the little bug.</p>\n'}, {'answer_id': 55158, 'author': 'rjzii', 'author_id': 1185, 'author_profile': 'https://Stackoverflow.com/users/1185', 'pm_score': 0, 'selected': False, 'text': "<p>I'm inclined to agree with the others; it sounds like one of the parameters you are passing SE.UI.Utilities.GetPermissionList is null which is causing the exception. Your best bet is to fire up the debugger and check was the variables are before that code is called.</p>\n"}, {'answer_id': 84541, 'author': 'Beriadan', 'author_id': 1983, 'author_profile': 'https://Stackoverflow.com/users/1983', 'pm_score': 0, 'selected': False, 'text': "<p>The <code>NullReferenceException</code> was actually thrown within a catch block so the stack trace couldn't display that line of code so instead it stopped at the caller. </p>\n\n<p>It was indeed one of the properties of the <code>l_Monitor</code> instance.</p>\n"}]
['https://Stackoverflow.com/questions/55130', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1983/']