xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

Forms 3.0: System.Reflection.AmbiguousMatchException #2632

Closed Sebastian1989101 closed 6 years ago

Sebastian1989101 commented 6 years ago

After the update to Xamarin.Forms 3.0 I got AmbiguousMatchException all over the place in my code. I'm not 100% why this happens and what it causes yet. A friend of mine got the same exceptions after the update - he has a complete different coding style and uses complete different libraries. Sadly he dosn't know why this happen and where it comes from.

System.Reflection.AmbiguousMatchException: Ambiguous match found.

05-08 16:01:25.641 D/Mono    ( 5777): DllImport attempting to load: '/system/lib/liblog.so'.
05-08 16:01:25.641 D/Mono    ( 5777): DllImport loaded library '/system/lib/liblog.so'.
05-08 16:01:25.642 D/Mono    ( 5777): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
05-08 16:01:25.642 D/Mono    ( 5777): Searching for '__android_log_print'.
05-08 16:01:25.642 D/Mono    ( 5777): Probing '__android_log_print'.
05-08 16:01:25.642 D/Mono    ( 5777): Found as '__android_log_print'.
05-08 16:01:25.648 I/MonoDroid( 5777): UNHANDLED EXCEPTION:
05-08 16:01:25.662 I/MonoDroid( 5777): System.Reflection.AmbiguousMatchException: Ambiguous match found.
05-08 16:01:25.662 I/MonoDroid( 5777):   at System.RuntimeType.GetPropertyImpl (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type returnType, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00061] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
05-08 16:01:25.662 I/MonoDroid( 5777):   at System.Type.GetProperty (System.String name) [0x0000e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Xamarin.Forms.BindingExpression.SetupPart (System.Reflection.TypeInfo sourceType, Xamarin.Forms.BindingExpression+BindingExpressionPart part) [0x00221] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:341 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x000d7] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:130 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Xamarin.Forms.BindingExpression.Apply (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property) [0x0006b] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:78 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Xamarin.Forms.Binding.Apply (System.Object newContext, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty, System.Boolean fromBindingContextChanged) [0x00057] in D:\a\1\s\Xamarin.Forms.Core\Binding.cs:131 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Xamarin.Forms.BindableObject.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding, System.Boolean fromStyle) [0x0008b] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:316 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Xamarin.Forms.BindableObject.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:94 
05-08 16:01:25.662 I/MonoDroid( 5777):   at MHWorldCompanion.Core.Pages.SetSearcherPage+<InitializeComponent>_anonXamlCDataTemplate_58.LoadDataTemplate () [0x00570] in <2bb6b8e8a7094c3ea0df28233dbe1b64>:0 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Xamarin.Forms.ElementTemplate.CreateContent () [0x00026] in D:\a\1\s\Xamarin.Forms.Core\ElementTemplate.cs:82 
05-08 16:01:25.662 I/MonoDroid( 5777):   at MHWorldCompanion.Core.Controls.ItemsStack.GetItemView (System.Object item) [0x00001] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\Controls\ItemsStack.cs:68 
05-08 16:01:25.662 I/MonoDroid( 5777):   at MHWorldCompanion.Core.Controls.ItemsStack.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00045] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\Controls\ItemsStack.cs:112 
05-08 16:01:25.662 I/MonoDroid( 5777):   at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
05-08 16:01:25.662 I/MonoDroid( 5777):   at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000f] in <5a97d41d36694fb19855c17429527b10>:0 
05-08 16:01:25.662 I/MonoDroid( 5777):   at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00009] in <5a97d41d36694fb19855c17429527b10>:0 
05-08 16:01:25.662 I/MonoDroid( 5777):   at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x00024] in <5a97d41d36694fb19855c17429527b10>:0 
05-08 16:01:25.662 I/MonoDroid( 5777):   at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
05-08 16:01:25.662 I/MonoDroid( 5777):   at MHWorldCompanion.Core.ViewModels.SetSearcherViewModel.ViewAppeared () [0x00027] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\ViewModels\SetSearcherViewModel.cs:146 
05-08 16:01:25.662 I/MonoDroid( 5777):   at MvvmCross.Forms.Views.MvxContentPage.OnAppearing () [0x00021] in <0afca477417f4241b92e240f7a530ede>:0 
05-08 16:01:25.662 I/MonoDroid( 5777):   at MHWorldCompanion.Core.Pages.SetSearcherPage.OnAppearing () [0x00001] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\Pages\SetSearcherPage.xaml.cs:24 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Xamarin.Forms.Page.SendAppearing () [0x00024] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:313 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.SendLifecycleEvent (System.Boolean isAppearing) [0x0004f] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:132 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnResume () [0x00011] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:117 
05-08 16:01:25.662 I/MonoDroid( 5777):   at Android.Support.V4.App.Fragment.n_OnResume (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <3682f8af23a748128467fbf9c57ae876>:0 
05-08 16:01:25.662 I/MonoDroid( 5777):   at (wrapper dynamic-method) System.Object.20042f24-e0c2-475b-ac40-41e0634ae0a6(intptr,intptr)
05-08 16:01:25.683 E/AppCenterCrashes( 5777): Unhandled Exception from source=AndroidEnvironment
05-08 16:01:25.683 E/AppCenterCrashes( 5777): System.Reflection.AmbiguousMatchException: Ambiguous match found.
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at System.RuntimeType.GetPropertyImpl (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type returnType, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00061] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at System.Type.GetProperty (System.String name) [0x0000e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at Xamarin.Forms.BindingExpression.SetupPart (System.Reflection.TypeInfo sourceType, Xamarin.Forms.BindingExpression+BindingExpressionPart part) [0x00221] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:341 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x000d7] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:130 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at Xamarin.Forms.BindingExpression.Apply (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property) [0x0006b] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:78 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at Xamarin.Forms.Binding.Apply (System.Object newContext, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty, System.Boolean fromBindingContextChanged) [0x00057] in D:\a\1\s\Xamarin.Forms.Core\Binding.cs:131 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at Xamarin.Forms.BindableObject.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding, System.Boolean fromStyle) [0x0008b] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:316 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at Xamarin.Forms.BindableObject.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:94 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at MHWorldCompanion.Core.Pages.SetSearcherPage+<InitializeComponent>_anonXamlCDataTemplate_58.LoadDataTemplate () [0x00570] in <2bb6b8e8a7094c3ea0df28233dbe1b64>:0 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at Xamarin.Forms.ElementTemplate.CreateContent () [0x00026] in D:\a\1\s\Xamarin.Forms.Core\ElementTemplate.cs:82 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at MHWorldCompanion.Core.Controls.ItemsStack.GetItemView (System.Object item) [0x00001] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\Controls\ItemsStack.cs:68 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at MHWorldCompanion.Core.Controls.ItemsStack.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00045] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\Controls\ItemsStack.cs:112 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000f] in <5a97d41d36694fb19855c17429527b10>:0 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00009] in <5a97d41d36694fb19855c17429527b10>:0 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x00024] in <5a97d41d36694fb19855c17429527b10>:0 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at MHWorldCompanion.Core.ViewModels.SetSearcherViewModel.ViewAppeared () [0x00027] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\ViewModels\SetSearcherViewModel.cs:146 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at MvvmCross.Forms.Views.MvxContentPage.OnAppearing () [0x00021] in <0afca477417f4241b92e240f7a530ede>:0 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at MHWorldCompanion.Core.Pages.SetSearcherPage.OnAppearing () [0x00001] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\Pages\SetSearcherPage.xaml.cs:24 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at Xamarin.Forms.Page.SendAppearing () [0x00024] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:313 
05-08 16:01:25.683 E/AppCenterCrashes( 5777):   at Xamarin.Forms.
05-08 16:01:25.692 D/Mono    ( 5777): Assembly Ref addref Microsoft.AppCenter.Crashes[0xa474e8e0] -> System.Core[0xa4419020]: 14
[0:] AndroidEnvironment.UnhandledExceptionRaiser: System.Reflection.AmbiguousMatchException: Ambiguous match found.
  at System.RuntimeType.GetPropertyImpl (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type returnType, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00061] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Type.GetProperty (System.String name) [0x0000e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Xamarin.Forms.BindingExpression.SetupPart (System.Reflection.TypeInfo sourceType, Xamarin.Forms.BindingExpression+BindingExpressionPart part) [0x00221] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:341 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x000d7] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:130 
  at Xamarin.Forms.BindingExpression.Apply (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property) [0x0006b] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:78 
  at Xamarin.Forms.Binding.Apply (System.Object newContext, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty, System.Boolean fromBindingContextChanged) [0x00057] in D:\a\1\s\Xamarin.Forms.Core\Binding.cs:131 
  at Xamarin.Forms.BindableObject.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding, System.Boolean fromStyle) [0x0008b] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:316 
  at Xamarin.Forms.BindableObject.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:94 
  at MHWorldCompanion.Core.Pages.SetSearcherPage+<InitializeComponent>_anonXamlCDataTemplate_58.LoadDataTemplate () [0x00570] in <2bb6b8e8a7094c3ea0df28233dbe1b64>:0 
  at Xamarin.Forms.ElementTemplate.CreateContent () [0x00026] in D:\a\1\s\Xamarin.Forms.Core\ElementTemplate.cs:82 
  at MHWorldCompanion.Core.Controls.ItemsStack.GetItemView (System.Object item) [0x00001] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\Controls\ItemsStack.cs:68 
  at MHWorldCompanion.Core.Controls.ItemsStack.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00045] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\Controls\ItemsStack.cs:112 
  at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000f] in <5a97d41d36694fb19855c17429527b10>:0 
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00009] in <5a97d41d36694fb19855c17429527b10>:0 
  at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x00024] in <5a97d41d36694fb19855c17429527b10>:0 
  at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at MHWorldCompanion.Core.ViewModels.SetSearcherViewModel.ViewAppeared () [0x00027] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\ViewModels\SetSearcherViewModel.cs:146 
  at MvvmCross.Forms.Views.MvxContentPage.OnAppearing () [0x00021] in <0afca477417f4241b92e240f7a530ede>:0 
  at MHWorldCompanion.Core.Pages.SetSearcherPage.OnAppearing () [0x00001] in C:\Privat\git\MHWorldCompanion\MHWorldCompanion\MHWorldCompanion.Core\Pages\SetSearcherPage.xaml.cs:24 
  at Xamarin.Forms.Page.SendAppearing () [0x00024] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:313 
  at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.SendLifecycleEvent (System.Boolean isAppearing) [0x0004f] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:132 
  at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnResume () [0x00011] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:117 
  at Android.Support.V4.App.Fragment.n_OnResume (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <3682f8af23a748128467fbf9c57ae876>:0 
  at (wrapper dynamic-method) System.Object.20042f24-e0c2-475b-ac40-41e0634ae0a6(intptr,intptr). IsTerminating: False
An unhandled exception occured.

05-08 16:01:37.181 E/mono-rt ( 5777): [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.AmbiguousMatchException: Ambiguous match found.
05-08 16:01:37.181 E/mono-rt ( 5777):   at (wrapper dynamic-method) System.Object.20042f24-e0c2-475b-ac40-41e0634ae0a6(intptr,intptr)
05-08 16:01:37.186 D/        ( 5777): HostConnection::get() New Host Connection established 0xa6e1f700, tid 5777
jamers99 commented 6 years ago

@ryanharding that fixed it! Thanks for the suggestion.

nadjibus commented 6 years ago

Getting it even with [XamlCompilation(XamlCompilationOptions.Compile)] (both page and assembly level)

vodevil commented 6 years ago

I just migrate from Xamarin Forms 2.5 to 3.1.0 and everything failed with AmbiguousMatchException at application start :(

godrose commented 6 years ago

You should clean and rebuild. This issue has been fixed in the June version.

On Wed, 1 Aug 2018 at 16:00 vodevil notifications@github.com wrote:

I just migrate from Xamarin Forms 2.5 to 3.1.0 and everything failed with AmbiguousMatchException at application start :(

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xamarin/Xamarin.Forms/issues/2632#issuecomment-409566070, or mute the thread https://github.com/notifications/unsubscribe-auth/AHbkI3r9wR8pFvWvtRo-hRHTMYmN3gtrks5uMaZcgaJpZM4T27Os .

-- Best Regards, Gena

alicint commented 6 years ago

I'm getting this error since I upgraded from Xamarin 2.5 to 3.2. I removed all the "Source={x:Reference Page}}" in my xaml file but still the error is there. any ideas what else can be the cause?

StephaneDelcroix commented 6 years ago

@alicint please open a new issue, with a reproduction. thx

txarito commented 5 years ago

Hello, i'm getting this error on new Project. VS2017 15.9.3, Xamarin Forms 3.4.0.1008975, .net Estándar 2.0 Page definition: <ContentPage x:Name="ViewX"...> In a control: Parent="{x:Reference ViewX}"

Remove last line solve runtime error, but obviously it's doens't works as expected.

Any workaround, solution?.

Many thanks

StephaneDelcroix commented 5 years ago

@txarito please open a new issue, with a reproduction. thx

EmilAlipiev commented 4 years ago

it is strange but this error was caused by livesharp for me. as referenced link