WinForms WebBrowser control crash on exit: Invalid URI: The URI is empty RRS feed

  • Question

  • Hi,

    I've experienced the following app crash (WinForms .NET 4.5) when closing the WebBrowser control:

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.UriFormatException: Invalid URI: The URI is empty.
    at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
    at System.Windows.Forms.WebBrowser.WebBrowserEvent.DocumentComplete(Object pDisp, Object& urlObject)
    --- End of inner exception stack trace ---
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

    The environment is Citrix with Windows Server 2012 R2 Standard. The crash is reproducible only on this particular machine. The URI is not empty. Document is opened with success in the control but crashes on exit. I couldn't reproduce it elsewhere. My app has handlers for Application.ThreadException and AppDomain.CurrentDomain.UnhandledException. The exception is caught by the AppDomain.CurrentDomain.UnhandledException. However the app is still crashing.

    I've tried the followings but with no success:

    1. added legacyunhandledexceptionpolicy enabled="1" in the app.config file.

    2. changed IE emulation for my app according to this article: https://www.cyotek.com/blog/configuring-the-emulation-mode-of-an-internet-explorer-webbrowser-control 

    Does anybody have a clue of what is happening ? Is there a bug in the WebBrowser control or an IE update that is causing this issue ?

    Thank you !
    Thursday, December 6, 2018 11:43 AM

All replies

  • Hi Stelian90,

    According to your description, the error is only caused on Citrix. Our forum do not support that, you could post a new thread in Citrix forum.


    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework, including Managed Extensibility Framework (MEF), Charting Controls, CardSpace, Windows Identity Foundation (WIF), Point of Sale (POS), Transactions.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 12, 2018 6:14 AM