MSProject Interop RPC_E_CALL_REJECTED

0

I'm facing a problem when reading 2400 tasks from a MS Project file. My code is running succesfully but after some time I'm getting the next error:

System.Runtime.InteropServices.COMException (0x80010001): Aanroep geweigerd door aangeroepene. (Uitzondering van HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)) bij Microsoft.Office.Interop.MSProject.Task.get_Name() bij _Default.MSPReadAll() in D:\Websites\WebSite1\MSP\Default.aspx.vb:regel 142

Sometimes it's after 140 tasks and the other time it is at 240 tasks. The less info I check the more tasks I can read. So I'm thinking of a kind of timeout. Hopefully somebody @stackoverflow can help me.

    Sub MSPReadAll()

    Try
        Dim appclass As New Application
        appclass.DisplayAlerts = False
        appclass.FileOpenEx(MppFile)
        appclass.Visible = True

        Dim project As Project = appclass.ActiveProject
        Dim oSubTask As Task
        Dim taskName As String
        Dim taskId As String
        Dim taskStart As Date
        Dim PrevTask As String = ""
        Dim SuperVisor As String = ""
        Dim aantal As Integer = 0
        Dim err As String = ""

        Dim totaal As Integer = project.Tasks.Count
        Response.Write(totaal.ToString)

        For Each oSubTask In project.Tasks
            Try
                aantal = aantal + 1
                taskId = oSubTask.UniqueID
                taskName = oSubTask.Name
                taskStart = oSubTask.Start
                PrevTask = oSubTask.Predecessors
                SuperVisor = oSubTask.Text18
                Response.Write("<p><strong>" & taskName & " (" & aantal & ")</strong><br>ID: " & taskId & "<br>Start: " & taskStart & "<br>PrevTask: " & PrevTask & "<br>SuperVisor: " & SuperVisor & "</p>")

            Catch ex2 As System.Exception
                Response.Write("EX2 " & ex2.ToString)
            End Try

        Next

        appclass.FileExit(PjSaveType.pjSave)

    Catch ex As System.Exception
        Response.Write(ex.ToString)
    End Try

End Sub
c#
.net
vb.net
interop
ms-project
asked on Stack Overflow Aug 25, 2020 by Heijnus • edited Aug 25, 2020 by Hassan Monjezi

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0