Issues with JavaScript errors in C# WebView objects & Visual Studio 2012

Today I was working on a Windows Store app in C# that uses a WebView object and I was running into an incredibly frustrating error: whenever I tried to load a webpage that had a JavaScript error, my application would crash with an unhandled exception. This window then asked me if I wanted to attach an available debugger by launching another instance of Visual Studio – which I had open, still in debug mode from when I ran the app. I tried multiple workarounds but I had several issues:

  • The Windows Store WebView object does not allow you to ignore script errors the way older iterations of the control did for traditional C# Windows apps
  • There was no way to catch JavaScript exceptions when they were thrown in the website
  • This bug showed up even after compiling and building in release mode
  • Every time I found a place where this question had been asked previously, there was no consistent answer on what was causing the problems.

I tried several fixes, but even setting breakpoints did nothing – every time I ran into a website that had scripting errors, my app was toast. It wasn’t until I found a post on Stack Overflow that took over six months to be answered that I discovered it was being caused by my settings in Visual Studio’s debugger.

Just goes to show that we’re always learning. I wish I understood a little more about what it was that was behind all of it – I can’t really understand why VS would attach a separate debugger to an executable that was already in the debug process. An adventure in application development to be sure.

Related Posts

Leave a Reply

Your email address will not be published.