title: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment
body: <p>I am getting this error when i try to show a form with an webbrowser in it.</p>
  
  <p><strong>ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment</strong></p>
  
  <p>I am calling it by:</p>
  
  <pre><code>Public Class frmMain
    Class Server
         Public Shared Sub Main()
          Dim aTcpMessaging As IMessagingSystemFactory = New TcpMessagingSystemFactory()
          Dim anInputChannel As IInputChannel = aTcpMessaging.CreateInputChannel(theIPforLocal &amp; ":" &amp; 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()
              Call New frmMM().Show()
         End Sub
    End Class
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Dim RelState As Integer = 0
      Call frmMain.Server.Main()
      lblVer.Text = "V.7"
      Pid = 0
    End Sub
  End Class
  </code></pre>
  
  <p>How can i load this up so it doesn't show me that error?</p>
  
  <p>Thanks.</p>
  
  <p>David</p>
  
  <p><strong>Code update</strong></p>
  
  <pre><code> Class Server
      &lt;STAThread()&gt; Public Sub Main()
          Dim aTcpMessaging As IMessagingSystemFactory = New TcpMessagingSystemFactory()
          Dim anInputChannel As IInputChannel = aTcpMessaging.CreateInputChannel(theIPforLocal &amp; ":" &amp; 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()
          Call New frmMM().Show()
     End Sub
   End Class
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Dim RelState As Integer = 0
      Call frmMain.Server.Main()   '&lt;-- the error now
      lblVer.Text = "V.7"
      Pid = 0
    End Sub
  End Class
  </code></pre>