How to resolve System.Reflection.Targetinvocationexception: Exception?

Asked

Viewed 2,848 times

0

My application (using Xamarin Forms) was working everything ok, more than anything when I click the login button it is being stopped triggering the following error:

System.Reflection.Targetinvocationexception: Exception has been thrown by the target of an Invocation.

How to solve this?

To be clear, there is no error in the script, everything is ok, because I was running everything ok and out of nowhere gave this. Target that in the list of errors there is nothing being displayed and already cleaned the solution and restarted the visual studio no more solved!

My shampoo from loginPage:

<ContentPage Title="Login">
    <ScrollView>
    <StackLayout Spacing="20" Padding="20"
                 VerticalOptions="Center">
        <Image 
        VerticalOptions="Center"
         HorizontalOptions="Center"
        Source="logo.png"/>

        <Entry x:Name="emailEntry" Placeholder="Usuário"
               Text="{Binding Usuario}"/>
        <Entry x:Name="senhaEntry" Placeholder="Senha"
               Text="{Binding Senha}"
               IsPassword="true"/>

        <ActivityIndicator x:Name="waitActivityIndicator"
                               HorizontalOptions="CenterAndExpand"
                               VerticalOptions="CenterAndExpand">
        </ActivityIndicator>
        <Button x:Name="loginButton"
                Text="Login" TextColor="White"
                BackgroundColor="#800000"
                Clicked="BtnLogin_Clicked"/>

    </StackLayout>
    </ScrollView>
</ContentPage>

And here the Codebehind:

public LoginPage()
{
    InitializeComponent();
    NavigationPage.SetHasNavigationBar(this, false);    
}

protected async void BtnLogin_Clicked(object sender, EventArgs e)
{
    App.Current.MainPage = new MainPageRoot();
}

This is Mainpagel XAML:

<?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="EbsHelpDesk.Views.MainPage"
             Title="Home">
    <ContentPage.Content>
        <ScrollView>
        <StackLayout Padding="20">
            <Label Text="Atendimentos em Aberto"
                   HorizontalOptions="Center"
                   VerticalOptions="Center"
                   FontAttributes="Bold"
                   FontSize="25"/>
                <Grid  ColumnSpacing="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions/>
                    <Label Text="#" Grid.Row="0" Grid.Column="0" FontAttributes="Bold"/>
                    <ListView x:Name="coluna0" Grid.Column="0" Grid.Row="1"  SeparatorColor="White"
                SeparatorVisibility="Default"/>
                    <Label Text="Colaborador" Grid.Row="0" Grid.Column="1" FontAttributes="Bold"/>
                    <ListView x:Name="coluna1" Grid.Column="1" Grid.Row="1"  SeparatorColor="White"
                SeparatorVisibility="Default"/>
                    <Label Text="Cliente" Grid.Row="0" Grid.Column="2" FontAttributes="Bold" />
                    <ListView x:Name="coluna2" Grid.Column="2" Grid.Row="1"  SeparatorColor="White"
                SeparatorVisibility="Default"/>
                    <Label Text="Duração" Grid.Row="0" Grid.Column="3" FontAttributes="Bold"/>
                    <ListView x:Name="coluna3" Grid.Column="3" Grid.Row="1"  SeparatorColor="White"
                SeparatorVisibility="Default"/>
                </Grid>

                <Label Text="Minhas Tarefas"
                   HorizontalOptions="Center"
                   VerticalOptions="Center"
                   FontAttributes="Bold"
                   FontSize="25"/>
                <Label Text="Sistema:"
                   HorizontalOptions="Center"
                   VerticalOptions="Center"
                   FontSize="12"/>
                <Picker x:Name="pckSistema" Title="Selecione o sistema:">
                    <Picker.Items>
                        <x:String>CORREÇÃO DE ERRO</x:String>
                        <x:String>MELHORIA DE SISTEMA</x:String>
                        <x:String>NOVA FUNCIONALIDADE</x:String>
                        <x:String>NOVO RELATÓRIO/ETIQUETA</x:String>
                        <x:String>OBRIGAÇÕES FISCAIS</x:String>
                        <x:String>MIGRAÇÃO DE SISTEMA</x:String>
                    </Picker.Items>
                </Picker>
                <Button Text="Criar Chamado"
                    TextColor="White"
                    BackgroundColor="#008000"
                    Image="tarefa24.png"
                    />
        </StackLayout>
        </ScrollView>
    </ContentPage.Content>
</ContentPage>
  • @LINQ is there no basis at all? If it’s not an error in the script, what should I put in the question then???

  • @Wpfan Relevant information (???) Where is running, what version of Xamarin, if the application arrives start, etc..

  • @LINQ plus it will be possible that no one reads the tag indicating what it refers not to, because I remember very well to have informed Xamarin-Forms.... and yes, the application starts, because as I warned the error only triggers when we click the LOGIN button!

  • 2

    Aren’t you trying to interact with some element or object that hasn’t been loaded yet? Always include code relevant to the time of error... We are not seeing your application and can’t guess what is happening without having something to interpret...

  • 1

    @Leandroangelo, what would be the code to report? Because the application shows nothing in the list of errors, only interrupted when it is running, triggering this error.... and another, it was running normal, without me touching anything, just closing and opening again then started giving it!! That sounds like Delphi, 'cause he’s the one who gets fucked like that!

  • 1

    @Wpfan, if the error is by clicking the login button... start by including the event code of that button click...

  • @Leandroangelo I will edit including, thank you, that is relevant comment!

  • @Wpfan would not be Application.Current instead of App.Current? You can also try adding a delay to the thread just to test.

  • @Leandroangelo, this syntax doesn’t make a difference, but I changed it anyway to confidence relief and it continues the same way! Man what could be causing this, my goodness... has completely delayed me here!

  • 2

    Without wanting to extend the discussion, I think we need to make a few things clear: The Stackoverflow community (and its users) has tools like signage, negative votes and comments to make their content relevant. The use of these resources does not give the right to anyone to disrespect the community. If a criticism is unfounded the community itself will disbelieve it over time. Flags and downvotes is also help, but in this case it helps the community, not a single individual. Anyway, see the expected behavior of our members [help/behavior]

Show 5 more comments

1 answer

2


Then I discovered that the mistake was in the XAML mainpage, simply remove the tag <Grid.RowDefinitions/>, then returned to function normally.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.