1

Redirecting to App.g.i.cs when loading a page in xamarin UWP. Code control comes to the following if block.

#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
        UnhandledException += (sender, e) =>
        {
            if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
        };
#endif

If I mouse over the e showing {Windows.UI.Xaml.UnhandledExceptionEventArgs}

I am not understanding what is the problem? Is this related to some error in XAML? This issue is only on the windows app, Android and IOS apps parts are working fine.

XAML page code:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Myproject.Pages.CodeValidationPage"
             BackgroundColor="#00aff0">

<ScrollView>
    <StackLayout
        VerticalOptions="FillAndExpand">
        <StackLayout 
        VerticalOptions="CenterAndExpand"
        Orientation="Vertical">

            <Image 
            Source="splash.png"
            HeightRequest="120"
            WidthRequest="120"
            IsVisible="True"
            HorizontalOptions="Center"
            VerticalOptions="CenterAndExpand"/>

            <Label
            Text=" Please check your email for the verification code and activate your account. "
            HorizontalOptions="CenterAndExpand"
                x:Name="italic_test"
            HorizontalTextAlignment="Center"
            Margin="3"
            Font="Italic,15"
            TextColor="White"/>

            <Frame
                HorizontalOptions="FillAndExpand"
                CornerRadius="10"
                Margin="20"
                Padding="0">

                <StackLayout 
                    BackgroundColor="White" 
                    Orientation="Vertical"
                    VerticalOptions="CenterAndExpand" >

                    <Entry 
                        x:Name="codeentry" 
                        Margin="10,10,10,0"
                        Keyboard="Numeric"
                        Placeholder="Enter Verification Code"/>

                    <Entry 
                        x:Name="passwordentry" 
                        Placeholder="Password" 
                        IsVisible="False"
                        Margin="10,10,10,0"
                        IsPassword="True"/>

                    <Entry 
                        x:Name="confirmpasswordentry" 
                        Margin="10,0,10,-10"
                        IsVisible="False"
                        Placeholder="Confirm Password"
                        IsPassword="True"/>

                    <Button
                        Text="Verify Code" 
                        HeightRequest="40"
                        WidthRequest="150"
                        x:Name="validationButton"
                        TextColor="White"
                        HorizontalOptions="CenterAndExpand"
                        Font="Bold,15"
                        Margin="5,15,5,10"
                        BorderRadius="20"
                        BackgroundColor="#00aff0" 
                        Clicked="SaveNewPassword"/>
                </StackLayout>
            </Frame>
        </StackLayout>

        <Label
            VerticalOptions="EndAndExpand"
            HorizontalOptions="CenterAndExpand"
            Margin="0,0,0,15"
                x:Name="backto_label"
                TextColor="White"
                Font="Bold,16"
                Text=" Back to Sign Up "/>
    </StackLayout>
</ScrollView>
</ContentPage>
Sreejith Sree
  • 3,055
  • 4
  • 36
  • 105
  • you have an unhandled exception. Set "DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION" in DefineConstants testbox in UWP project settings to not reach this line. – magicandre1981 Dec 12 '18 at 15:55
  • @magicandre1981 I can't find any defineconstants textbox in UWP project, I have added the screenshot to the question when going to the project properties. Can you please tell on which tab I can find that option? – Sreejith Sree Dec 13 '18 at 05:03
  • under [Build you see the option](https://i.stack.imgur.com/xnz6V.png) – magicandre1981 Dec 13 '18 at 16:28
  • @magicandre1981 I disable the define DEBUG constant checkbox in the build tab, but no luck. I added a screenshot to the question with the latest observations. – Sreejith Sree Dec 14 '18 at 03:41
  • Hi @SreejithSree, you could check rob's [case reply](https://social.msdn.microsoft.com/Forums/en-US/250e8e87-8eff-4af3-b957-2cf12d7ee89c/can-you-disable-the-disablexamlgeneratedbreakonunhandledexception-flag?forum=winappswithcsharp), in my opinion, you need to check if all the component has been init successfully and the local resource has load correctly. And most problems occur on resource loading. – Nico Zhu Dec 14 '18 at 08:06
  • @NicoZhu-MSFT Edited the question with latest observations, can you please help? – Sreejith Sree Dec 14 '18 at 14:29
  • don't disable debug. looks like you copied/pasted some code you fond somewhere. Use a simple DisplayAlert to show a message with the exception string in unhandled handler. – magicandre1981 Dec 14 '18 at 15:15
  • I could not figure out what is `NathsarTS` in your screenshot. It looks like reference project. could you share mini sample? – Nico Zhu Dec 17 '18 at 03:01
  • @NicoZhu-MSFT "Use a simple DisplayAlert to show a message with the exception string in unhandled handler" - Can you please share this sample code? I didn't get how to write this? – Sreejith Sree Dec 17 '18 at 04:10
  • From your screenshot, `NathsarTS` does not exist, you could check if `NathsarTS` component exist in your project. – Nico Zhu Dec 17 '18 at 04:17
  • @NicoZhu-MSFT From the following link I got that code. Can you please go through that and tell what is `NathsarTS?` Is that a Nuget Package? https://social.msdn.microsoft.com/Forums/en-US/250e8e87-8eff-4af3-b957-2cf12d7ee89c/can-you-disable-the-disablexamlgeneratedbreakonunhandledexception-flag?forum=winappswithcsharp – Sreejith Sree Dec 17 '18 at 05:05
  • @magicandre1981 and NicoZhu-MSFT: For fixing an issue in UWP, I changed the target and min versions of UWP app. Is that changes cause this issue? For more details please go to the following thread. https://stackoverflow.com/questions/53706578/reference-to-type-assembly-claims-it-is-defined-in-system-runtime-but-it-co – Sreejith Sree Dec 17 '18 at 05:27
  • I have checked that case. `NathsarTS` is not nuget package, it is separate common reference library. And you could not copy/paste code. – Nico Zhu Dec 17 '18 at 05:33
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/185339/discussion-between-sreejith-sree-and-nico-zhu-msft). – Sreejith Sree Dec 17 '18 at 06:02
  • The problem is definitely in XAML, so you should post some code so that we can see what is happening – Martin Zikmund Dec 17 '18 at 09:02
  • @magicandre1981 created a sample, can you please look. https://1drv.ms/u/s!AqQr83WMykhefGVlORsBqi1rlNs – Sreejith Sree Dec 17 '18 at 11:59
  • @MartinZikmund I added the XAML code of a page to the question, when I load this page I am getting this error. Can you please look? – Sreejith Sree Dec 17 '18 at 12:03
  • I posted it as answer what I did to get the app running. – magicandre1981 Dec 17 '18 at 17:21
  • You should not convert to .NET Framework, but to .NET Standard library. That is a different concept. Please look into the documentation to see how to create a .NET Standard library and migrate your code there – Martin Zikmund Dec 19 '18 at 08:59
  • @MartinZikmund So sorry, actually I converted to .Net standared, not to .NET Framework. I used PclToNetStandard.vsix for converting the pcl to .NET Standard as per the answer of magicandre1981. – Sreejith Sree Dec 19 '18 at 09:16
  • @MartinZikmund I created a new sample for you. Can you please check? Which is a .NET Standard project, converted from PCL.https://1drv.ms/u/s!AqQr83WMykhefgh7vtU0nMCchu0 – Sreejith Sree Dec 19 '18 at 10:34
  • @MartinZikmund I have the issue when doing `signup, reset password and join operations`. When doing reset password use `geo@rsvhr.com` as the email. For join enter 5 and search, then click the join button for the test site. – Sreejith Sree Dec 19 '18 at 10:39

2 Answers2

2

With Xamarin.forms 3.x Microsoft moved to .net standard 2.0.

I was able to compile the code and run the app after converting your PCL to .net standard 2.0, updating all nuget packages to last version and changing xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions" to xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin" as stated in the documentation in your XAML files.

enter image description here

Clicking on ResetPassword shows a System.Collections.Generic.KeyNotFoundException at this line:

string initialLogin = Application.Current.Properties["initialLogin"].ToString();

So change it to

Application.Current.Properties.TryGetValue("initialLogin", out var initialLogin);

to handle the case that "initialLogin" was not added to the Application.Current.Properties collection. Next check the value for being != null before use it.

Also in Mainpage.xaml.cs you do the same mistake with username and password.

Also change PDB type from full to pdb-only to allow debugging. This is a known issue.

So reset works:

enter image description here

magicandre1981
  • 27,895
  • 5
  • 86
  • 127
  • How many time it take to install? VSIX installer is still running after 1 hour? – Sreejith Sree Dec 18 '18 at 13:24
  • close VS2017 and click on end tasks – magicandre1981 Dec 18 '18 at 15:26
  • post more details what I should use as test credentials. – magicandre1981 Dec 19 '18 at 15:10
  • I have the issue on `sign up, password reset and Join operations`. For sign up, you can use any details, enter any `first name, last name and email`. When click the submit button will get that error page. Also when do reset password getting the same error. Please use `geo@rsvhr.com` as the reset password email. You can see a join option in the new sample at the bottom of login page. When click join a new page will come, please enter 5 in the entry and tap search option. Then a community with Join button will show in in the UI. When click the join button will get the same error. – Sreejith Sree Dec 20 '18 at 05:05
  • Thank you very much for your time and advice, I updated the right answer. – Sreejith Sree Jan 03 '19 at 04:37
0

The real problem is with the disaplayalert.

I am using the following code for display alert:

await DisplayAlert("Alert", "A verification code has been sent to your email.", "OK");

If I changed the above lines like below, no issue will come.

Device.BeginInvokeOnMainThread(async () => 
{
    await DisplayAlert("Alert", "A verification code has been sent to your email.", "OK");
});
Sreejith Sree
  • 3,055
  • 4
  • 36
  • 105