The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

My Code is

Private Function GetXlUsedRange(ByVal filePath As String) As Object(,)
        Dim xlApp As Excel.Application
        Dim xlWorkbooks As Excel.Workbooks
        Dim xlWorkbook As Excel.Workbook
        Dim xlSheets As Excel.Sheets
        Dim xlWorkSheet As Excel.Worksheet
        Dim xlRange As Excel.Range


        xlApp = New Excel.Application
        xlWorkbooks = xlApp.Workbooks
        xlWorkbook = xlWorkbooks.Open(filePath)
        xlSheets = xlWorkbook.Worksheets
        xlWorkSheet = CType(xlSheets("Data"), Excel.Worksheet)
        xlRange = xlWorkSheet.UsedRange

        Dim rangeValues(,) As Object
        rangeValues = CType(xlRange.Value, Object(,))


        xlWorkbook.Close()
        xlWorkbooks.Close()
        xlApp.Quit()

        releaseObject(xlRange)
        releaseObject(xlWorkSheet)
        releaseObject(xlSheets)
        releaseObject(xlWorkbook)
        releaseObject(xlWorkbooks)
        releaseObject(xlApp)

        Return rangeValues
    End Function

    Private Sub releaseObject(ByVal obj As Object)
        Try
            System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
            obj = Nothing
        Catch ex As Exception
            obj = Nothing
        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim usedRange(,) As Object = GetXlUsedRange("C:\Users\Jayanta Modak\Desktop\import.xls")

        Dim fromRow As Integer = 7
        PopulateListView(usedRange, fromRow)
    End Sub

Have you tried looking at the answers on this page?

Click Here

commented: Welcome back. Been a while. +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.