Showing results for 
Search instead for 
Do you mean 

LMS Test.Lab Automation Casting Failed when Using AdvancedCmd Interface

[ Edited ]

Hello Gurus,


I'm trying to do a block average in Automation and when defining the AdvCmd function I got a Casting error.

Dim AdvCmd As LMSTestLabAutomation.ICmdAdvanced

AdvCmd = TestLabAutomation.Application.cmd.AdvancedCmd

Then I got the error:


{"Unable to cast COM object of type 'System.__ComObject' to interface type 'LMSTestLabAutomation.ICmdAdvanced'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{40800206-046B-4B0E-AD5F-0D5F14E9AA96}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."}


I see in the examples (example 6) a similar comment about a Casting failure.


Would anyone the fix?






Full code:

Private Sub AvgCalc_Click(sender As Object, e As EventArgs) Handles AvgCalc.Click
        Dim CurrentBlockOctaveName As String
        Dim blockAveraged As LMSTestLabAutomation.IBlock
        Dim cmd As LMSTestLabAutomation.ICmd
        Dim AdvCmd As LMSTestLabAutomation.ICmdAdvanced
        Dim AvgParam As Object = 1
        Dim AvgType As LMSTestLabAutomation.CONST_EnumStatisticFunction = LMSTestLabAutomation.CONST_EnumStatisticFunction.StatisticFunctionEnergy_average

            'Delete the folder if it already exists
            GlV.database.Delete(GlV.currentPath + "/Averaged")
        Catch ex As Exception

        End Try

        GlV.database.AddFolder(GlV.currentPath, "Averaged")
        cmd = GlV.TL.cmd
        AdvCmd = GlV.TL.cmd.AdvancedCmd
        blockAveraged = GlV.myInputBasket(SelectedIndexes(1), False)

        If GlV.currentPath <> "" Then

            For Each Index As Integer In SelectedIndexes

                currentBlock = GlV.myInputBasket(Index, False)
                currentBlockOctave = GlV.TL.cmd.BLOCK_OCTAVE(currentBlock)
                CurrentBlockOctaveName = currentBlock.Label
                GlV.database.AddItem(GlV.currentPath, CurrentBlockOctaveName, currentBlockOctave, Nothing, 1)
                blockAveraged = AdvCmd.BLOCK_AVERAGE_STATISTICS(AvgParam, AvgType, blockAveraged, currentBlockOctave)
                GlV.database.AddItem(GlV.currentPath + "/Averaged", CurrentBlockOctaveName, currentBlockOctave, Nothing, 1)


            MessageBox.Show("Please select the Output Data Path")
            Exit Sub

        End If

    End Sub




Re: LMS Test.Lab Automation Casting Failed when Using AdvancedCmd Interface

try this line

oBlock = tl.cmd.AdvancedCmd.BLOCK_AVERAGE_STATISTICS(1, LMSTestLabAutomation.CONST_EnumStatisticFunction.StatisticFunctionEnergy_average, oBlock, oBlock)