17

I have a <WebView> control on a page in my application. The user can pretty much enter whatever URL they like and have it display in this WebView. This is by design.

The problem is, there are pages on the internet that throw JavaScript errors, and (for some reason) cause an unhandled exception to bubble up through the .NET application, as well.

My question is: Where do I catch JavaScript exceptions/errors when using a <WebView>?

Nate
  • 30,286
  • 23
  • 113
  • 184
qJake
  • 16,821
  • 17
  • 83
  • 135
  • 1
    What's bizarre is that they don't even seem to get bubbled up into the application unhandled event. I have a debugger attached yet when bad js is executed it prompts me to attach a debugger to what seems like the same process and it will actually take me to the location in the js where the exception happens. I have no idea how to prevent it or handle it... – justin.m.chase Jul 08 '12 at 05:01
  • Report it to Microsoft, they are supposed to provide an error handler on web view. – Akash Kava Jan 02 '13 at 19:42

1 Answers1

22

I had the same problem. it was somehow related to just-in-time debugging for Scripts. Try the following (from VS 2012): Uncheck the Scripts box in Debug -> Options and Settings -> Debugging -> Just in time

Worked for me.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Neil Schaper
  • 336
  • 3
  • 4
  • Any idea how to do this in VS 2013? – Markus Johnsson Jun 17 '14 at 12:26
  • 1
    I have a HTML app that uses iframe for Web context operation (ms-appx-web://) and Javascript errors in the iframe causes the whole app to crash. The Visual Studio settings don't work, since it is Waahost.exe that doesn't like it. So inside or outside Visual Studio the app will still crash. – icelava Oct 29 '14 at 05:49
  • This is still happening in 2020 on Windows 1903 with Edge HTML 18 without Visual Studio – bhantol Oct 29 '20 at 13:17