VB.Net - Excel-COM-Objekt wird nicht freigegeben [duplizieren]

Diese Frage hat hier bereits eine Antwort:

Anwendung wird nach dem Aufruf von quit @ nicht beend 8 answers

Ich stehe vor einem Problem, bei dem der Excel-Prozess auch nach dem Aufrufen der ReleaseComObject- und GC.Collect-Methode aktiv bleibt.

Mein Excel-Prozess wird beendet, aber NUR nachdem ich das Benutzerformular geschlossen habe

Below ist ein Beispielcode, der zeigt, was ich alles mache, um den Excel-Prozess loszuwerden:

Public Class frmTEST
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim objExcel As xl.Application
        Dim wbReport As xl.Workbook = Nothing

        objExcel = CreateObject("Excel.Application")

        Try
            wbReport = objExcel.Workbooks.Open("D:\EL\Nicolas\VS Online\Classe A v2\Launcher-v2.2\Resources\Modules\Zoom.xlsm")
        Catch ex As Exception
            Common.WriteDebugLog("Exception line 44")
        End Try
        If wbReport Is Nothing Then
            MsgBox("Erreur d'ouverture du reporting - Code 745.", vbExclamation)
            Exit Sub
        End If

        With objExcel
            .Visible = False
            .ScreenUpdating = False
            .Calculation = xl.XlCalculation.xlCalculationManual
            .DisplayAlerts = False
        End With

        '' Here I do all my processing which I have removed to make the question more simplified

        With objExcel
            .Calculation = xl.XlCalculation.xlCalculationAutomatic
            .ScreenUpdating = True
            .DisplayAlerts = True
        End With

        ''~~> Close & Clean Up
        wbReport.Close(SaveChanges:=False)
        objExcel.Quit()

        Me.ReleaseObject(wbReport)
        Me.ReleaseObject(objExcel)

        MsgBox("Done")
    End Sub

    Private Sub ReleaseObject(ByVal obj As Object)
        Try
            Dim intRel As Integer = 0
            Do
                intRel = System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
            Loop While intRel > 0
            MsgBox("Final Released obj # " & intRel)
        Catch ex As Exception
            MsgBox("Error releasing object" & ex.ToString)
            obj = Nothing
        Finally
            GC.Collect()
        End Try
    End Sub
End Class

AKTUALISIERE: Aufgrund von Kommentaren, die ich erhalten habe, habe ich nach dem @ Änderungen an meinem Code vorgenommeweiterer Thread, aber es hilft immer noch nicht. Mein Excel-Prozess wird jedoch NUR beendet, nachdem ich User Form @ geschlossen hab

Antworten auf die Frage(2)

Ihre Antwort auf die Frage