title: MPXJ consistently adds blank task name...is MPXJ better than Interop?
body: <p>I'm trying to use MPXJ to create project file from a hierarchy that exists in my code.  The following hierarchy needs to be converted:</p>
  
  <ul>
  <li>Division
  <ul>
  <li>Customer
  <ul>
  <li>Contract
  <ul>
  <li>Projects
  <ul>
  <li>Project details (start/end dates, etc.)</li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>My code for creating the .mpx is as follows:</p>
  
  <pre><code>private void BuildExport()
      {
  
          net.sf.mpxj.ProjectFile file = new net.sf.mpxj.ProjectFile();
          net.sf.mpxj.ProjectCalendar cal = file.addDefaultBaseCalendar();
  
          //Microsoft.Office.Interop.MSProject.Application projApp = new Microsoft.Office.Interop.MSProject.Application();
          //projApp.Visible = true;
          //projApp.FileNew();
  
          string firstDate = string.Empty;
  
          foreach (IZCpTreeViewItem div in Divisions)
          {
              net.sf.mpxj.Task divTask = file.addTask();
              divTask.setName(div.Name);
  
              //Microsoft.Office.Interop.MSProject.Task newTask = projApp.ActiveProject.Tasks.Add(div.Name);
  
              //newTask.OutlineLevel = 1;
  
              foreach (IZCpTreeViewItem cust in div.Subitems)
              {
                  net.sf.mpxj.Task custTask = null;
  
                  if (cust.Subitems.Count &gt; 0)
                  {
                      custTask = divTask.addTask();
                      custTask.setName(cust.Name);
                  }                    
  
                  //Microsoft.Office.Interop.MSProject.Task custTask = newTask.OutlineChildren.Add(cust.Name);
  
                  //custTask.OutlineLevel = 2;
  
                  foreach (IZCpTreeViewItem contractVm in cust.Subitems)
                  {
                      net.sf.mpxj.Task contTask = custTask.addTask();
                      contTask.setName(contractVm.Name);
  
                      //Microsoft.Office.Interop.MSProject.Task contractTask = custTask.OutlineChildren.Add(contractVm.Name);
  
                      //contractTask.OutlineLevel = 3;
  
                      foreach (ZCpProjectViewModel proj in (contractVm as ZCpContractViewModel).Projects)
                      {
                          net.sf.mpxj.Task projTask = contTask.addTask();
                          projTask.setName(proj.Name);
  
                          //Microsoft.Office.Interop.MSProject.Task projTask = contractTask.OutlineChildren.Add(proj.Project.Name);
  
                          //projTask.OutlineLevel = 4;
  
                          foreach (ZCpProjectDetailViewModel detail in proj.ProjectDetail)
                          {
                              net.sf.mpxj.Task projDTask = projTask.addTask();
                              projDTask.setName(detail.ProjectDetail.CostClass);
                              projDTask.setStart(detail.StartDate.HasValue ? new java.util.Date(detail.StartDate.ToString()) : null);
  
                              //Microsoft.Office.Interop.MSProject.Task projDetailTask = projTask.OutlineChildren.Add(detail.ProjectDetail.CostClass);
  
                              //projDetailTask.Start = String.Format("{0}", detail.StartDate.ToString());
                              //projDetailTask.Finish = String.Format("{0}", detail.EndDate.ToString());
  
                              //projDetailTask.OutlineLevel = 5;
                          }
                      }
                  }
              }
          }
  
          net.sf.mpxj.writer.ProjectWriter writer = new MPXWriter();
          writer.write(file, "example.mpx");
      }
  </code></pre>
  
  <p>The commented out code is the interop code I was using before I found MPXJ.  My problem is that after I run this block, my .mpx file has some customers that are blank (even though I put breakpoints in when adding these customers and ensured the names were not empty).  Is there something else I need to set to ensure all names are use?</p>
  
  <p>Should I just go back to using the incredibly slow (17 minutes to create ~6000 tasks) interop code.  Is there a way to write to the Projcet file using interop without having the Project file open.</p>
  
  <p>Thanks!!</p>