#region Overridden Class Methods
/// <summary>
/// Occurs when this command is created
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
if (hook == null)
return;
m_application = hook as IApplication;
//Disable if it is not ArcScene
//if (hook is ISxApplication)
// base.m_enabled = true;
//else
base.m_enabled = false;
// TODO: Add other initialization code
UID cmdUID = new UIDClass();
cmdUID.Value = "esriArcScene.SxAddDataCommand";
** ICommandBars docBars = m_application.Document.CommandBars;**
m_xoomCommand = docBars.Find(cmdUID, false, false);
//Enable only when the delegate command is available
base.m_enabled = m_xoomCommand != null;
}
/// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
// TODO: Add AddData.OnClick implementation
m_xoomCommand.Execute();
}
#endregion
问题出现在加粗的部分
m_application
m_application.Document
m_application.Document.CommandBars
这三个变量哪个是null?