Reputation: 4257
I have an UWP App targeting the FCU. Since today I get the following exception:
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to class type 'System.String'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
at MoneyFox.Windows.Views.AccountListView.AccountListView_obj1_Bindings.Update_CurrentBalance(Double obj, Int32 phase)
at MoneyFox.Windows.
As far as I can see it happens as soon as a binding with the type double to a TextBlock should update. But I haven't changed anything on that code.
I have the latest VS 15.7.3. Also I made tries with targeting different platforms and different versions of Microsoft.NETCore.UniversalWindowsPlatform (currently 6.0.8).
The Link to the repository: https://github.com/NPadrutt/MoneyFox.Windows/tree/XamarinFormsNew
What can that be?
Upvotes: 0
Views: 390
Reputation: 4257
I found the issue.. I have a converter who implements IValueConverter by Xamarin.Forms as well as inherits from MvxValueConverter so I can use it for Xamarin Forms Bindings aswell as with my UWP app withouth XF.
public class AmountFormatConverter : MvxValueConverter, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// Converter Logic
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
// Convert Back Logic
}
}
My issue here was, that I didn't set the the Override keyword for the implemented methods. It seems that caused the issue.
public class AmountFormatConverter : MvxValueConverter, IValueConverter
{
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// Converter Logic
}
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
// Convert Back Logic
}
}
Upvotes: 2