我有一个针对FCU的UWP应用。从今天起我得到以下例外:
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.
据我所知,只要对TextBlock的double类型的绑定应该更新,就会发生这种情况。但是我对这段代码没有任何改变。
我有最新的VS 15.7.3。此外,我尝试针对不同的平台和不同版本的Microsoft.NETCore.UniversalWindowsPlatform(目前为6.0.8)。
存储库链接:https://github.com/NPadrutt/MoneyFox.Windows/tree/XamarinFormsNew
那可能是什么?
答案 0 :(得分:2)
我发现了问题..我有一个转换器,它通过Xamarin.Forms实现IValueConverter以及继承自MvxValueConverter,所以我可以将它用于Xamarin Forms Bindings以及我的UWP应用程序而不用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
}
}
我的问题是,我没有为已实现的方法设置Override关键字。这似乎引起了这个问题。
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
}
}