Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile error when inheriting from class

This is my class called BoolToVisibilityValueConverter:

public class BoolToVisibilityValueConverter : MvxValueConverter<bool, ViewStates>
{
    protected override ViewStates Convert(bool value, Type targetType, object parameter, CultureInfo culture)
    {
        return value ? ViewStates.Visible : ViewStates.Gone;
    }

    protected override bool ConvertBack(ViewStates value, Type targetType, object parameter, CultureInfo culture)
    {
        return ViewStates.Visible == value;
    }
}

It inherits from MvxValueConverter which is a generic class taking parameters From and To. The source of the MvxValueConverter can be found on Github under MvvmCross' repository - MvxValueConverter.

I can build the project, run it and see it works. I am using Visual Studio 2015 with the latest Xamarin and the latest version of MvvmCross (4.0.0)

However, on our TeamCity server same build fails:

[14:40:06][Csc] ValueConverters\BoolToVisibilityValueConverter.cs(10, 33): error CS0115: 'MyProject.Droid.ValueConverters.BoolToVisibilityValueConverter.Convert(bool, System.Type, object, System.Globalization.CultureInfo)': no suitable method found to override

[14:40:06][Csc] ValueConverters\BoolToVisibilityValueConverter.cs(15, 27): error CS0115: 'MyProject.Droid.ValueConverters.BoolToVisibilityValueConverter.ConvertBack(Android.Views.ViewStates, System.Type, object, System.Globalization.CultureInfo)': no suitable method found to override

Error CS0115 from MSDN happens when A method was marked as an override, but the compiler found no method to override. The TeamCity has Visual Studio 2013 installed.

Why does my build fail?

like image 200
Nikola Avatar asked Dec 28 '25 16:12

Nikola


1 Answers

You need to open your android projects .csproj file, and manually add a reference to System.Globalization

like image 169
user1202032 Avatar answered Dec 30 '25 06:12

user1202032



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!