如何debuggingNullReferenceException发生在base.Dispose(configuration)样板

我是C#和VSTO的新手。

我有一个Excel添加,我有工作,创build一个function区和一些新的button,做各种事情。

我得到一个NullReferenceException base.Dispose Ribbon.Designer.cs文件中发生的插件加载到Excel中。

从文档说我可能实例化了一些东西,而不使用新的关键字,但我不知道在哪里可以find我没有做的事情!

我今天早些时候有这个工作,但没有采取任何备份或连接到源代码pipe理,事后看来是一个坏主意!

在例外的时候有很多的空值,我不知道这是否有意义?

基本上; 我不知道我做了什么突然发生这种情况,我不知道如何debugging它,在哪里设置我的rest,或者这个样板如何适合事情的scheme。

当我没有包括绝大多数的代码时,我并不指望有人魔法般的把错误带出去,但是一些方向或者解释什么是好的!

当地人窗口在例外的时候

- this {ReportFramework.Ribbon} ReportFramework.Ribbon - base {ReportFramework.Ribbon} Microsoft.Office.Tools.Ribbon.RibbonBase {ReportFramework.Ribbon} + base {ReportFramework.Ribbon} System.ComponentModel.Component {ReportFramework.Ribbon} Base null Microsoft.Office.Tools.Ribbon.OfficeRibbon + Context '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).Context' threw an exception of type 'System.NullReferenceException' object {System.NullReferenceException} Factory null Microsoft.Office.Tools.Ribbon.RibbonFactory + Global '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).Global' threw an exception of type 'System.NullReferenceException' bool {System.NullReferenceException} + Name '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).Name' threw an exception of type 'System.NullReferenceException' string {System.NullReferenceException} + OfficeMenu '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).OfficeMenu' threw an exception of type 'System.NullReferenceException' Microsoft.Office.Tools.Ribbon.RibbonOfficeMenu {System.NullReferenceException} + Parent '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).Parent' threw an exception of type 'System.NullReferenceException' Microsoft.Office.Tools.Ribbon.RibbonComponent {System.NullReferenceException} + RibbonId '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).RibbonId' threw an exception of type 'System.NullReferenceException' string {System.NullReferenceException} + RibbonType '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).RibbonType' threw an exception of type 'System.NullReferenceException' string {System.NullReferenceException} + RibbonUI '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).RibbonUI' threw an exception of type 'System.NullReferenceException' Microsoft.Office.Core.IRibbonUI {System.NullReferenceException} + StartFromScratch '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).StartFromScratch' threw an exception of type 'System.NullReferenceException' bool {System.NullReferenceException} + Tabs '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).Tabs' threw an exception of type 'System.NullReferenceException' System.Collections.Generic.IList<Microsoft.Office.Tools.Ribbon.RibbonTab> {System.NullReferenceException} + Tag '((Microsoft.Office.Tools.Ribbon.RibbonBase)(this)).Tag' threw an exception of type 'System.NullReferenceException' object {System.NullReferenceException} + Non-Public members btnAddCETotals null Microsoft.Office.Tools.Ribbon.RibbonButton btnLinkBank null Microsoft.Office.Tools.Ribbon.RibbonButton btnCEDataTransfer null Microsoft.Office.Tools.Ribbon.RibbonButton *...More btn's* IsClose false bool LargeColWidth 0.0 double + objCReport {ReportFramework.Classes.CReport} ReportFramework.Classes.CReport objFormat null ReportFramework.Classes.CFormat oExcel null Microsoft.Office.Interop.Excel.Application PageWidthLandscape 0.0 double PageWidthPortrait 0.0 double SmallColWidth 0.0 double tabBoyceTools null Microsoft.Office.Tools.Ribbon.RibbonTab userName null string WorksheetResult null Microsoft.Office.Interop.Excel.Worksheet disposing false bool 

exception细节

  System.NullReferenceException was unhandled HResult=-2147467261 Message=Object reference not set to an instance of an object. Source=Microsoft.Office.Tools.Common.v4.0.Utilities StackTrace: at Microsoft.Office.Tools.Ribbon.RibbonBase.Dispose(Boolean disposing) at ReportFramework.Ribbon.Dispose(Boolean disposing) in C:\Users\lsmith\Documents\Visual Studio 2010\Projects\xxx Tools 2\ReportFramework\Ribbon.Designer.cs:line 30 at System.ComponentModel.Component.Finalize() InnerException: 

第30行是底部

Ribbon.Designer.cs

 namespace ReportFramework { partial class Ribbon : Microsoft.Office.Tools.Ribbon.RibbonBase { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; public Ribbon() : base(Globals.Factory.GetRibbonFactory()) { InitializeComponent(); } /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Component Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.tabBoyceTools = this.Factory.CreateRibbonTab(); this.grpBoyceCAL = this.Factory.CreateRibbonGroup(); this.btnGenerateCAL = this.Factory.CreateRibbonButton(); *...Lots more code here; not sure if it's pertinent. can post if necessary.* } partial class ThisRibbonCollection { internal Ribbon Ribbon { get { return this.GetRibbon<Ribbon>(); } } } }