Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

WebView HtmlWebViewSource crashing the app

masroorejaz1985masroorejaz1985 Member ✭✭
edited January 2019 in Xamarin.Forms


I want to display html text using webview. Currently I am testing it on UWP. Problem is whenever I use WebView in my current XAML code it's crashes the app and throw exception on the last page. I even tried using some hard quote value but even that's not working.

My XAML Code:


        <Image x:Name="ProductDetailsImage" WidthRequest="200" HeightRequest="200"></Image>
        <Label x:Name="ProductDetailsName" ></Label>
        <Label x:Name="ProductDetailsStartingFrom" ></Label>
        <Label x:Name="ProductDetailsBrand" ></Label>
        <Label x:Name="ProductDetailsSKU" ></Label>
        <Label x:Name="ProductDetailsMPN" ></Label>
        <Label x:Name="ProductDetailsStockStatus" ></Label>
        <Label x:Name="ProductDiscontinued" Text="Non-Returnable" IsVisible="False" ></Label>

        <Picker x:Name="SelectColorPicker" ItemDisplayBinding="{Binding name_str}" 
                SelectedItem="{Binding option_value_id}" IsVisible="False" Title="Select Color:"

        <Picker x:Name="SelectSizePicker" ItemDisplayBinding="{Binding name_str}"
                SelectedItem="{Binding option_value_id}" IsVisible="False" Title="Select Size:" 

        <Label Text="Enter Quantity: " x:Name="LabelQty" IsVisible="False"></Label>
        <Entry x:Name="ProductQty" Text="1" IsVisible="False"></Entry>
        <Button x:Name="AddToCart" Text="Add to Cart" IsVisible="False" Clicked="AddToCart_Clicked"></Button>
        <Button x:Name="AddToWishlist" Text="Add to Wishlist" IsVisible="False" Clicked="AddToWishlist_Clicked"></Button>     

        <WebView HeightRequest="100" WidthRequest="100">
                <HtmlWebViewSource x:Name="ProductHtmlWebViewSource"></HtmlWebViewSource>


Code Behind:

ProductHtmlWebViewSource.Html =;

Any help would be appreciated.

Thank you

Best Answer


  • JoeMankeJoeManke USMember ✭✭✭✭✭

    What is the exception?

  • It is throwing System.ArgumentNullExcption

    Exception thrown: 'System.ArgumentNullException' in System.Private.CoreLib.dll
    The thread 0x1154 has exited with code 0 (0x0).
    The thread 0x3488 has exited with code 0 (0x0).
    An exception of type 'System.ArgumentNullException' occurred in System.Private.CoreLib.dll but was not handled in user code
    Value cannot be null.

    The program '[1472] NayaDemoApp.UWP.exe' has exited with code -1 (0xffffffff).

  • Thanks a lot for the help @JoeManke

    It's working fine now.

  • Sean.AndersonSean.Anderson USMember ✭✭

    I wasted a few days chasing down crazy exceptions when loading a WebView. I was assigningpublic HtmlWebViewSource HtmlSource = new HtmlWebViewSource() as the view model-bound property without setting the Html property of the HtmlWebViewSource. An empty HtmlWebViewSource.Html encountered by a WebView, for some reason, causes a flaming crash. public HtmlWebViewSource HtmlSource = new HtmlWebViewSource() { Html = "some html"}; resolved the NullExceptions spiraling out of Windows and up through Xamarin.

Sign In or Register to comment.