This project has moved. For the latest updates, please go here.

PowerPoint.Application reference is null using GetHostItem

Apr 2, 2013 at 11:29 PM
Hi, I'm converting a Powerpoint Addin using the traditional interop assemblies to NetOffice.

I've updated references everywhere to refer to the NetOffice objects, and my project now compiles again, but fails at runtime trying to get a reference to the current PowerPoint.Application object.

A snippet of the failing code is below. PowerPoint refers to NetOffice.PowerPointApi, whereas before it referred to Microsoft.Office.Interop.PowerPoint.

This is code generated by the designer tool in visual studio, so I don't know if I should keep using the GetHostItem or what.

Any clues welcome.
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "10.0.0.0")]
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
        protected override void Initialize() {
            base.Initialize();
            this.Application = this.GetHostItem<PowerPoint.Application>(typeof(PowerPoint.Application), "Application");
            if (this.Application == null)
            {
                MessageBox.Show("Application is null :-(");
            }
            Globals.PowerPointAddin = this;
            global::System.Windows.Forms.Application.EnableVisualStyles();
            this.InitializeCachedData();
            this.InitializeControls();
            this.InitializeComponents();
            this.InitializeData();
        }