实例化对象的NullReferenceException?

这是我inheritance的应用程序的一段代码,用户有一个黄色的死亡屏幕:

你调用的对象是空的

在线上:

bool l_Success ... 

现在我95%确定错误的参数是ref l_Monitor ,这是非常奇怪的,考虑到对象之前被实例化了几行。 任何人都知道为什么会发生这种情况? 请注意,我在代码中的其他位置弹出了相同的问题。

 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实例上访问的其中一个属性不为null吗?

暂时为该(loooooongg)行上的所有属性查询注入几个变量。 运行调试器,检查值并转移小错误。

我倾向于同意其他人; 它听起来像你传递的参数之一SE.UI.Utilities.GetPermissionList是null导致exception。 最好的办法是启动调试器,并在调用代码之前检查变量。

NullReferenceException实际上是在catch块中抛出的,因此堆栈跟踪无法显示该行代码,因此它在调用者处停止。

它确实是l_Monitor实例的属性之一。