none
COM Error when instantiating MSProject "ApplicationClass" object (Interop/C#/.NET)

    Question

  • Hi,

    Firstly, I hope I'm posting this in the right place - there's lots of info out there about using .NET and the COM Interops with Excel and Word - and I have written many applications using these methods - but not much on programming Project in this way.

    I am looking to create a Windows Forms program which opens an existing Project 2003 file - just the file; no server interaction whatsoever - processes the data it contains and then passes it on.  Sadly I'm falling at the first hurdle.  If I were doing Excel or Word I would first create an instance of the Interop's "ApplicationClass", then create a related Workbook or Document respectively.  Reading what information is out there on the net, this seems like a valid approach, but I'm getting a COM error.

    Here's my code, edited a bit for brevity:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using msp = Microsoft.Office.Interop.MSProject;
    using System.Runtime.InteropServices;
    
    namespace ProjectMangle
    {
      public partial class MainForm : Form
      {
        private msp.ApplicationClass p_app;
    
        public MainForm()
        {
          InitializeComponent();
        }
    
        public void Finalize()
        {
          if (p_app != null)
          {
            p_app.Quit();
            Marshal.ReleaseComObject(e_app);
          }
        }
    
        #region UI Handlers
        private void btFileLoad_Click(object sender, EventArgs e)
        {
          doLoadFile();
        }
    
        private void btQuit_Click(object sender, EventArgs e)
        {
          doClose();
        }
        #endregion
    
        private void doClose()
        {
          // close
          this.Close();
        }
    
        private void doLoadFile()
        {
          try
          {
            p_app = new msp.ApplicationClass();
          }
          
          catch (COMException ex)
          {
            Console.WriteLine(ex.Message);
          } 
        }
      }
    }
    
    Running this code gets me the following error:

    Creating an instance of the COM component with CLSID {36D27C48-A1E8-11D3-BA55-00C04F72F325} from the IClassFactory failed due to the 
    following error: 80010001.

     

    If anyone could throw some light on whats causing this I'd me most grateful - I have tried most of solutions I have found out on the net - all of those that seem to have a similar situation - with no joy.

    If you need any more info, please ask.  If I've posted this to the wrong place, please advise as to the more appropriate location and I will move the discussion there.

    Thank you for your time.

    David Falconer.

     

    Monday, May 24, 2010 1:55 PM