how to solve this error? (vb.net & ms project)
Dim theFile As String
OpenFileDialog1.InitialDirectory = Application.ExecutablePath
OpenFileDialog1.DefaultExt = "mpp" 'custom format
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "Microsoft Project Files" _
& " (*.mpp)|*.mpp"
OpenFileDialog1.ShowDialog()
theFile = OpenFileDialog1.FileName
Dim pj As New MSProject.Application
pj.Visible = True
pj.FileOpen(theFile)
Debug.Print(pj.ActiveProject.Name)
Debug.Print(pj.ActiveProject.Tasks.Count)
Dim tsk As MSProject.Application
For Each tsk In pj.ActiveProject.Tasks
Debug.Print(pj.ActiveProject.Name)
Next
The error message I got is Unable to cast COM object of type 'System.__ComObject' to interface type 'MSProject.Application'. How to solve this problem?

