在实例化对象上是否存在NullReferenceException? [英] NullReferenceException on instantiated object?

查看:69
本文介绍了在实例化对象上是否存在NullReferenceException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我继承的应用程序中的一段代码,用户死于黄屏:

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

对象引用未设置为对象的实例

Object reference not set to an instance of an object

在线:

bool l_Success ... 

现在,我有95%的把握确定错误的参数是 ref l_Monitor ,考虑到对象在几行之前被实例化,这是非常奇怪的.有人知道为什么会发生吗?请注意,我在代码的其他地方也看到了同样的问题.

Now I'm 95% sure the faulty argument is ref l_Monitor 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.

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);

推荐答案

您确定尝试在l_Monitor实例上访问的属性之一不为空吗?

You sure that one of the properties trying to be accessed on the l_Monitor instance isn't null?

这篇关于在实例化对象上是否存在NullReferenceException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆