0

I'm having a weird issue with VB.net I am trying to add a cefsharp control on my form, but can't seem to find any way to do it.

The problem is that the code is not executed at all, i am not getting any errors or warnings, yet no message box is showing.

I have tried adding a try/catch block, and to open a message box in case of exception.

The app is executed and a clean form is being shown, no messagebox or anything.

If i remove entierly the try/catch block, it's showing the first message box.

Thanks

Imports CefSharp
Imports CefSharp.WinForms

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    MsgBox("start")
    Me.WindowState = FormWindowState.Maximized
    Try
        Dim x As WebView
        x = New WebView("http://www.google.ro", New BrowserSettings())
    Catch ex As Exception
        MsgBox("error")
    End Try
    msgbox("finished")
end sub    
Dilvish5
  • 310
  • 4
  • 12
  • Do you have first chance exceptions enabled? Debug->Exceptions->Common Language Runtime -> check "Thrown". If not, turn them on and report back any exceptions you see when re-running the code. – Tom Studee Jun 12 '14 at 00:23
  • I have turned them on, but no exceptions are showing when running the app. – Dilvish5 Jun 12 '14 at 00:27
  • You're declaring a local variable (`x`) and assigning it a value by creating the WebView, but the variable goes out of scope at `end sub` and therefore is discarded by garbage collection (it basically is thrown away). Declare the variable at a higher scope than the local sub. – Ken White Jun 12 '14 at 01:16
  • see if this question/answer is applicable http://stackoverflow.com/a/4934010/479512 – Mark Hall Jun 12 '14 at 02:26
  • The problem seemed to be happening because the references were not being copied to the debug folder. Thanks for the help. – Dilvish5 Jun 12 '14 at 22:22

1 Answers1

0

You say that you're trying to add a control to your form but there's no code there that actually does that. You create a WebView so I expect that that's the control. Like any other control, you have to actually add it to the form:

Me.Controls.Add(x)
jmcilhinney
  • 50,448
  • 5
  • 26
  • 46