的NullReferenceException实例化对象? [英] NullReferenceException on instanciated object?
本文介绍了的NullReferenceException实例化对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是从我所继承的应用程序code的一个片段,用户有死亡的黄色画面:
对象引用不设置到对象的实例
块引用>就行了:
布尔l_Success ...
现在我95%肯定有问题的说法是
REF l_Monitor
这是非常奇怪的考虑对象实例化前几行。任何人都有一个线索,为什么会发生这种事?请注意,我已经看到了同样的问题在code等地流行起来。IDMS.Monitor l_Monitor =新IDMS.Monitor();
l_Monitor.LogFile.Product_ID =SE_WEB_APP;如果(m_PermType_RadioButtonList.SelectedIndex == -1){
l_Monitor.LogFile.Log(
Nortel.IS.IDMS.LogFile.MessageTypes.ERROR,
没有权限类型选择
);
返回;
}
布尔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实例访问一个不为空?
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
on the line:
bool l_Success ...
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);
解决方案You sure that one of the properties trying to be accessed on the l_Monitor instance isn't null?
这篇关于的NullReferenceException实例化对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文