另外新建一个线程来运行webbrowser:
这是我的测试代码:
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
'MsgBox("OnStart")
Try
Dim t1 As New Threading.Thread(AddressOf RunWebBrowser)
t1.SetApartmentState(Threading.ApartmentState.STA)
t1.Start()
EventLog1.WriteEntry(" t.Start()")
Catch ex As Exception
EventLog1.WriteEntry(ex.Message, EventLogEntryType.Error)
Me.ExitCode = 100
Me.Stop()
End Try
End Sub
Private Sub RunWebBrowser()
Dim wb As New WebBrowser
wb.Navigate("www.microsoft.com")
End Sub
希望有用。
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
