Base solution for your next web application
Open Closed

LoginView DI issue on iOS Mobile Device #9664


User avatar
0
devinedon created

.NET Core 3.1 Angular ANZ 9.0.1

Hey,

I get the following error only when running the iOS application on my iPhone. When using the simulator its fine. On Android it works fine on both a simulator and a physical device. Its at runtime after the splash screen stage has completed.

Unhandled Exception *: Castle.MicroKernel.ComponentActivator.ComponentActivatorException: ComponentActivator: could not instantiate SynapWare.Views.LoginView ---> System.InvalidCastException: Specified cast is not valid.


10 Answer(s)
  • User Avatar
    0
    devinedon created

    Any update?

  • User Avatar
    0
    alper created
    Support Team

    I checked LoginView there are 3 classes that can throw this exception.

    1. LoginViewModel.cs
    2. LoginView.xaml
    3. LoginView.xaml.cs

    I checked all these 3 files, there doesn't seem to be a cast operation in the class initializations. can you get a full stack exception

  • User Avatar
    0
    devinedon created

    Sorry, my bad, will get this to you tomorrow. Thanks! Still find it very strange that it works using the emulator but not on a physical device.... hmmm

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @devinedon

    Did you get a chance to find the full stack trace ?

  • User Avatar
    0
    devinedon created

    Hey @ismcagdas

    Sadly my Macbook Pro 2015 has decided to no longer turn on :( Busy organising a replacement machine. Will get back to you ASAP.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @devinedon

    In the mean time, could you share your;

    1. ABP NuGet package verison
    2. AutoMapper version in one of the mobile projects (*.Mobile.Droid will work) ?
  • User Avatar
    0
    devinedon created

    So sorry for the delayed repsonse.

    ABP - 5.13 Automapper - 10

    I think I already tried automapper version 10 to fix this - think this is why im on this instead of 9 for ANZ 9.2.0 RC1 (which is what currently on)

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    It is really hard to trakc this problem. Maybe this could help you https://stackoverflow.com/a/48732272/6681451

  • User Avatar
    0
    devinedon created

    Thanks @ismcagdas,

    I dont make use of DataTemplates on the login page.

    Setup iOS dev on my new iMac and same error; only an issue on a physical device (iPhone 11 pro, 14.3 if it matters at all)

    My LoginView.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:Name="LoginPage"
                 xmlns:base="clr-namespace:SynapWare.ViewModels.Base;assembly=SynapWare.Mobile.Shared"
                 xmlns:extensions="clr-namespace:SynapWare.Extensions.MarkupExtensions;assembly=SynapWare.Mobile.Shared"
                 xmlns:behaviors="clr-namespace:SynapWare.Behaviors;assembly=SynapWare.Mobile.Shared"
                 xmlns:controls="clr-namespace:SynapWare.Controls;assembly=SynapWare.Mobile.Shared"
                 xmlns:buttons="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
                 x:Class="SynapWare.Views.LoginView"
                 BackgroundColor="{StaticResource LoginBackgroundColor}"
                 base:ViewManager.AutoWireViewModel="true"
                 NavigationPage.HasNavigationBar="False"
                 Title="{extensions:Translate LogIn}">
    
        <ContentPage.ToolbarItems>
            <controls:HideableToolbarItem 
                Order="Primary" 
                Text="{extensions:Translate ChangeTenant}"  
                Command="{Binding ChangeTenantCommand}" 
                IsVisible="{Binding IsMultiTenancyEnabled}"
                ParentPage="{x:Reference LoginPage}" />
        </ContentPage.ToolbarItems>
    
        <ContentPage.Content>
            <ScrollView>
                <Grid RowDefinitions="0.10*, 150, auto, auto, 0.20*" ColumnDefinitions="*, 18*, *"
                      RowSpacing="0"
                      ColumnSpacing="0">
                    
                    <Image  Grid.Row="1"   
                        Grid.Column="1"
                        Aspect="AspectFit"
                        Source="{extensions:ImageSource 'SynapWare.UI.Assets.Images.Synap_Black_Teal.png'}">
                    </Image>
    
                    <!--<Frame Grid.Row="2"
                       Grid.Column="1" 
                       IsVisible="{Binding IsMultiTenancyEnabled}"
                       Style="{StaticResource RoundedFrame}">
    
                        <Grid Padding="0" ColumnSpacing="5" RowSpacing="0" HorizontalOptions="Center">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0.5*"/>
                                <ColumnDefinition Width="0.5*"/>
                            </Grid.ColumnDefinitions>
    
                            <Label Grid.Row="0"
                            Grid.Column="0"
                            LineBreakMode="WordWrap"
                            Text="{extensions:Translate CurrentTenant}"  />
    
                            <Label Grid.Row="0"
                            Grid.Column="1"
                            LineBreakMode="WordWrap"
                            Text="{Binding CurrentTenancyNameOrDefault}"  
                            Style="{StaticResource ActiveLabel}"/>
    
                        </Grid>
    
                    </Frame>-->
    
                    <Frame Grid.Row="3" BackgroundColor="White" BorderColor="White"
                        Grid.Column="1"
                        Style="{StaticResource RoundedFrame}">
    
                        <StackLayout VerticalOptions="StartAndExpand" Spacing="0">
    
                            <Label Text="{extensions:Translate UserNameOrEmail}" TextColor="{StaticResource PrimaryColor}" />
                            <Entry Text="{Binding UserName, Mode=TwoWay}"  
                               Keyboard="{StaticResource NoCapitalizationKeyboard}"
                               x:Name="UsernameEntry"/>
    
                            <Label Text="{extensions:Translate Password}" Margin="0,10,0,0" TextColor="{StaticResource PrimaryColor}" />
                            <Entry IsPassword="True" 
                               Text="{Binding Password, Mode=TwoWay}" 
                               Keyboard="{StaticResource NoCapitalizationKeyboard}"
                               x:Name="PasswordEntry"/>
    
                            <Label Text="{extensions:Translate ForgotPassword}" 
                                   FontSize="Micro"
                                   HorizontalOptions="EndAndExpand"
                                   TextColor="{StaticResource PrimaryColor}"
                                   Margin="0,10,0,0">
                                <Label.GestureRecognizers>
                                    <TapGestureRecognizer Command="{Binding ForgotPasswordCommand}" />
                                </Label.GestureRecognizers>
                            </Label>
    
                            <buttons:SfButton Text="{extensions:Translate LogIn}" x:Name="LoginButton" Margin="0,20,0,0"
                                    IsEnabled="{Binding IsLoginEnabled}"
                                    Style="{StaticResource ActionButton}"
                                    Command="{Binding LoginUserCommand}" 
                                    CornerRadius="25"/>
    
                            <!--<Label Text="{extensions:Translate EmailActivation}" 
                                   HorizontalOptions="StartAndExpand" 
                                   TextColor="{StaticResource PrimaryColor}"
                                   Margin="0,10,0,0">
                                <Label.GestureRecognizers>
                                    <TapGestureRecognizer Command="{Binding EmailActivationCommand}" />
                                </Label.GestureRecognizers>
                            </Label>-->
    
                            <!--<Picker Title="{extensions:Translate Languages}" 
                                    Margin="0,10,0,0"
                                    ItemsSource="{Binding Languages}" 
                                    ItemDisplayBinding="{Binding DisplayName}"
                                    SelectedItem="{Binding SelectedLanguage}"/>-->
    
                        </StackLayout>
                    </Frame>
    
                </Grid>
            </ScrollView>
        </ContentPage.Content>
    
        <ContentPage.Behaviors>
            <behaviors:EventHandlerBehavior EventName="Appearing">
                <behaviors:ActionCollection>
                    <behaviors:InvokeCommandAction Command="{Binding PageAppearingCommand}" />
                </behaviors:ActionCollection>
            </behaviors:EventHandlerBehavior>
        </ContentPage.Behaviors>
    
    </ContentPage>
    
  • User Avatar
    0
    devinedon created

    So, good news! It works if go back to default loginview.xaml. Must be something to do with my styling. Will report back asap

    EDIT : Syncfusion related. Only does this on a physical iOS device, Android and iOS emulator works 100%. Working - License related :/ Sorry about that