ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment

后端 未结 4 2046
予麋鹿
予麋鹿 2021-01-22 20:54

I am getting this error when i try to show a form with an webbrowser in it.

ActiveX control \'8856f961-340a-11d0-a96b-00c04fd705a2\' cannot be instantiated becau

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 21:37

    Class Server
     Public Sub Main()
        Dim aTcpMessaging As IMessagingSystemFactory = New TcpMessagingSystemFactory()
        Dim anInputChannel As IInputChannel = aTcpMessaging.CreateInputChannel(theIPforLocal & ":" & thePort)
        Dim aStringMessagesFactory As IStringMessagesFactory = New StringMessagesFactory()
        Dim aStringMessageReceiver As IStringMessageReceiver = aStringMessagesFactory.CreateStringMessageReceiver()
        AddHandler aStringMessageReceiver.MessageReceived, AddressOf StringMessageReceived
    
        aStringMessageReceiver.AttachInputChannel(anInputChannel)
    End Sub
    
    Private Shared Sub StringMessageReceived()
      Dim t As New Threading.Thread(AddressOf ShowFP)
    
      t.SetApartmentState(Threading.ApartmentState.STA)
      t.Start()
     End Sub
    End Class
    
    Private Shared Sub ShowFP()
      Dim ShowFP As New frmFPVid
      ShowFP.ShowDialog()
    End Sub
    

提交回复
热议问题