We have a code sequence that reads tasks from an MPP file. It used to work fine, however since applying the last Office updates the code fails at the line
var tasks = project.Tasks
with an InvalidCastException ("Return argument has an invalid type", HR=-2147467262).
Has something changed in the Microsoft Project 2013 object model?
Below you have a code sequence that used to work fine and now it fails:
var app = new Microsoft.Office.Interop.MSProject.ApplicationClass();var toOpen = @"d:\work\test.mpp";
var succeeded = app.FileOpen(toOpen);
if (!succeeded)
{
Console.WriteLine("Cannot open file");
return;
}
var project = app.ActiveProject;
var tasks = project.Tasks;