Click here to Skip to main content
15,843,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The error is:
Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.

What I have tried:

My code is:
Private Sub PlayList_SelectedIndexChanged(sender As Object, e As EventArgs) Handles PlayList.SelectedIndexChanged
        For Each Song As ListViewItem In PlayList.SelectedItems
            MP3 = New ID3.ID3Info(Song.Tag.ToString, True)
            NameLbl.Text = MP3.ID3v1Info.Title
            ArtistLbl.Text = MP3.ID3v1Info.Artist
            YearLbl.Text = MP3.ID3v1Info.Year

            For x As Integer = 0 To PlayList.Items.Count - 1
                Dim song As WMPLib.IWMPMedia = MP.newMedia(PlayList.Items(x).ToString)
        Catch ex As Exception
        End Try

    End Sub

This code is copied from other forums.
Updated 2-Mar-23 21:18pm

1 solution

The public properties and methods of an ActiveX control can only be referenced after the ActiveX control has been instantiated and initialized completely; otherwise the AxHost.InvalidActiveXStateException exception is thrown. The AxHost.InvalidActiveXStateException exception class contains the name of the member that made the reference and the member type. The member type is one of the AxHost.ActiveXInvokeKind enumerated values.

You can read more at MS - AxHost.InvalidActiveXStateException Class[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900