tiger4589 / Xamarin.Forms-CardView

A Package to create a CardView using Xamarin.Forms that works on the three platforms (Android, iOS, UWP)
MIT License
66 stars 16 forks source link

Getting TypeInitializationException #7

Open mrbelk opened 6 years ago

mrbelk commented 6 years ago

Trying to upgrade my app to Prism v7 (preview 3), Xamarin.Forms 2.5.0.121934, and CardView 1.1.1.1.

When I try to navigate to a form containing some cardview controls on it, I am getting this error:

At the time of the exception, the container was: 
[mono-rt]   Resolving StormFueling.Views.StormFuelingPage,StormFuelingPage (mapped from System.Object, StormFuelingPage)
[mono-rt]   Calling constructor StormFueling.Views.StormFuelingPage()
[mono-rt]  ---> System.TypeInitializationException: The type initializer for 'CardView.CardView' threw an exception. ---> System.ArgumentException: Default value did not match return type
[mono-rt] Parameter name: defaultValue
[mono-rt]   at Xamarin.Forms.BindableProperty..ctor (System.String propertyName, System.Type returnType, System.Type declaringType, System.Object defaultValue, Xamarin.Forms.BindingMode defaultBindingMode, Xamarin.Forms.BindableProperty+ValidateValueDelegate validateValue, Xamarin.Forms.BindableProperty+BindingPropertyChangedDelegate propertyChanged, Xamarin.Forms.BindableProperty+BindingPropertyChangingDelegate propertyChanging, Xamarin.Forms.BindableProperty+CoerceValueDelegate coerceValue, Xamarin.Forms.BindableProperty+BindablePropertyBindingChanging bindingChanging, System.Boolean isReadOnly, Xamarin.Forms.BindableProperty+CreateDefaultValueDelegate defaultValueCreator) [0x0008a] in D:\agent\_work\1\s\Xamarin.Forms.Core\BindableProperty.cs:74 
[mono-rt]   at Xamarin.Forms.BindableProperty.Create (System.String propertyName, System.Type returnType, System.Type declaringType, System.Object defaultValue, Xamarin.Forms.BindingMode defaultBindingMode, Xamarin.Forms.BindableProperty+ValidateValueDelegate validateValue, Xamarin.Forms.BindableProperty+BindingPropertyChangedDelegate propertyChanged, Xamarin.Forms.BindableProperty+BindingPropertyChangingDelegate propertyChanging, Xamarin.Forms.BindableProperty+CoerceValueDelegate coerceValue, Xamarin.Forms.BindableProperty+CreateDefaultValueDelegate defaultValueCreator) [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Core\BindableProperty.cs:132 
[mono-rt]   at CardView.CardView..cctor () [0x00073] in <1f7204124e6c4b1e9064b0989c5a1a9e>:0 

The XAML I am using to set up a cardview looks like this:

                <cv:CardView CardViewOutlineColor="Black"
                    CardViewHasShadow="true"
                    Grid.Row="0"
                    Grid.Column="0">

                    <cv:CardView.HeightRequest>
                        <OnPlatform x:TypeArguments="x:Double">
                            <On Platform="Android" Value="213" />
                            <On Platform="iOS" Value="203" />
                        </OnPlatform>
                    </cv:CardView.HeightRequest>

                    <cv:CardView.Margin>
                        <OnPlatform x:TypeArguments="Thickness">
                            <On Platform="iOS" Value="0,0,0,4" />
                        </OnPlatform>
                    </cv:CardView.Margin>

                    <cv:CardView.GestureRecognizers>
                        <TapGestureRecognizer NumberOfTapsRequired="1"
                            Command="{Binding ContractorFuelingCommand}" />
                    </cv:CardView.GestureRecognizers>

                    <cv:CardView.CardViewContent>

                        <Grid HorizontalOptions="FillAndExpand"
                            VerticalOptions="Start"
                            BackgroundColor="White">

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="40" />
                            </Grid.RowDefinitions>

                            <Image Source="contractor_fuel_card.png"
                                Aspect="AspectFill"
                                Grid.Row="0"
                                Grid.Column="0" />

                            <Label Text="Contractor Fueling"
                                HorizontalOptions="Start"
                                VerticalOptions="End"
                                FontSize="Large"
                                TextColor="White"
                                Margin="16, 0, 16, 8"
                                Grid.Row="0"
                                Grid.Column="0" />

                            <controls:FlatButton HorizontalOptions="Start"
                                BackgroundColor="Transparent"
                                VerticalOptions="End"
                                HeightRequest="40"
                                Text="START"
                                TextColor="{StaticResource bizRed}"
                                Grid.Row="1"
                                Grid.Column="0">
                                <controls:FlatButton.Margin>
                                    <OnPlatform x:TypeArguments="Thickness">
                                        <On Platform="iOS" Value="8,0,0,0" />
                                    </OnPlatform>
                                </controls:FlatButton.Margin>
                            </controls:FlatButton>

                        </Grid>
                    </cv:CardView.CardViewContent>

                </cv:CardView>

Any ideas why I might be getting this all of a sudden? I am trying to run on an Android emulator with API23.

Thanks

tiger4589 commented 6 years ago

I will look into that.

Sorry for my late response, I have been so busy lately. Can you please share a demo project reproducing this problem so I can look into it more?