Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Using axwebbrowser control and thread locking app

tim2006tim2006 Member Posts: 1
When i try to run the program, it just hangs. If i remove the axwebbrowser control it works fine.

Any ideas?

Here is my code:

Imports System.Windows.Forms
Imports System.Threading

Public Class Class1
Public Shared form1 As New Form1

Shared Sub Main(ByVal Args() As String)
Dim t2 As Thread

t2 = New Thread(AddressOf screen)

End Sub
Shared Sub screen()

End Sub
End Class

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

'This call is required by the Windows Form Designer.

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
End If
End If
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents AxWebBrowser1 As AxSHDocVw.AxWebBrowser
Friend WithEvents Button1 As System.Windows.Forms.Button
Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.AxWebBrowser1 = New AxSHDocVw.AxWebBrowser
Me.Button1 = New System.Windows.Forms.Button
CType(Me.AxWebBrowser1, System.ComponentModel.ISupportInitialize).BeginIni t()
Me.AxWebBrowser1.Enabled = True
Me.AxWebBrowser1.Location = New System.Drawing.Point(48, 24)
Me.AxWebBrowser1.OcxState = CType(resources.GetObject("AxWebBrowser1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxWebBrowser1.Size = New System.Drawing.Size(300, 150)
Me.AxWebBrowser1.TabIndex = 0
Me.Button1.Location = New System.Drawing.Point(440, 72)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(584, 272)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.AxWebBrowser1, System.ComponentModel.ISupportInitialize).EndInit( )

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class


  • LunaroxLunarox Member Posts: 1
    I am experiencing a similar problem. Wondering if you found a solution?

    My scenario:
    I have an ancient, purchased, no longer supported, Ax control (Unix message bus type control) that requires a Form in order to function. I want to use this Ax control in a VB .NET Windows Service. I'm using VS 2008.

    My design and complexities aside, I created a form and added the Ax control to it. I then created a separate Single-Threaded Apartement (STA) thread to run the form and process messages. The trouble occurs on startup, the form thread hangs in the method 'InitializeComponent', at the (shortened) code line:

    Of course, as you've stated, removing the Ax control allows the form to start, but then I don't have the use of that control. :)

    In order to simplify testing my code, I created the form object and thread in a 'Windows Form Application'. It works well there, without fail. Then stuffing the same code into a Windows Service framework, the trouble starts.

Sign In or Register to comment.