You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently upgraded to Xamarin Forms 4.8 and now I see that whenever the application loads it throws the following exception:
UnhandledException:
System.TypeInitializationException: The type initializer for 'MagicGradients.GradientView' threw an exception.---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.---> System.ArgumentException: An item with the same key has already been added. Key: background
at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert(TKeykey,TValuevalue,System.Collections.Generic.InsertionBehaviorbehavior)[0x0015a]in/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:572
at System.Collections.Generic.Dictionary`2[TKey,TValue].Add(TKeykey,TValuevalue)[0x00000]in/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:240
at (wrappermanaged-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)at System.Reflection.RuntimeMethodInfo.Invoke(System.Objectobj,System.Reflection.BindingFlagsinvokeAttr,System.Reflection.Binderbinder,System.Object[]parameters,System.Globalization.CultureInfoculture)[0x0006a]in/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395---End of inner exception stack trace ---atSystem.Reflection.RuntimeMethodInfo.Invoke (System.Objectobj,System.Reflection.BindingFlagsinvokeAttr,System.Reflection.Binderbinder,System.Object[]parameters,System.Globalization.CultureInfoculture)[0x00081]in/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:409at System.Reflection.MethodBase.Invoke(System.Objectobj,System.Object[]parameters)[0x00000]in/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Reflection/MethodBase.cs:53at MagicGradients.StyleSheets.RegisterStyle(System.Stringname,System.TypetargetType,System.StringbindablePropertyName)[0x000a7]in<b9be2afa08cb4dab98018a1af7e6eeba>:0at MagicGradients.GradientView..cctor()[0x00035]in<b9be2afa08cb4dab98018a1af7e6eeba>:0---End of inner exception stack trace ---at(wrapperdynamic-method) Android.Runtime.DynamicMethodNameCounter.8(intptr,intptr,intptr)at(wrappernative-to-managed) Android.Runtime.DynamicMethodNameCounter.8(intptr,intptr,intptr)[ERROR]FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'MagicGradients.GradientView' threw an exception.---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.---> System.ArgumentException: An item with the same key has already been added. Key: background
at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert(TKeykey,TValuevalue,System.Collections.Generic.InsertionBehaviorbehavior)[0x0015a]in/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:572
at System.Collections.Generic.Dictionary`2[TKey,TValue].Add(TKeykey,TValuevalue)[0x00000]in/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:240
at (wrappermanaged-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)at System.Reflection.RuntimeMethodInfo.Invoke (System.Objectobj,System.Reflection.BindingFlagsinvokeAttr,System.Reflection.Binderbinder,System.Object[]parameters,System.Globalization.CultureInfoculture)[0x0006a]in/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395--- End of inner exception stack trace ---
at System.Reflection.RuntimeMethodInfo.Invoke (System.Objectobj,System.Reflection.BindingFlagsinvokeAttr,System.Reflection.Binderbinder,System.Object[]parameters,System.Globalization.CultureInfoculture)[0x00081]in/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:409
at System.Reflection.MethodBase.Invoke (System.Objectobj,System.Object[]parameters)[0x00000]in/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Reflection/MethodBase.cs:53
at MagicGradients.StyleSheets.RegisterStyle (System.Stringname,System.TypetargetType,System.StringbindablePropertyName)[0x000a7]in<b9be2afa08cb4dab98018a1af7e6eeba>:0
at MagicGradients.GradientView..cctor ()[0x00035]in<b9be2afa08cb4dab98018a1af7e6eeba>:0---End of inner exception stack trace ---at(wrapperdynamic-method) Android.Runtime.DynamicMethodNameCounter.8(intptr,intptr,intptr)at(wrappernative-to-managed) Android.Runtime.DynamicMethodNameCounter.8(intptr,intptr,intptr)
If I migrate back to V4.7 the application works as expected.
I have also attached a sample application, which is using Xamarin Forms 4.8, and shows the exception.
Hi @mauro-dasilva, thanks for reporting. This issues is caused by Brushes introduced in Forms 4.8 which are using background property for CSS styling, same as GradientView and we have a conflict. Issue is being investigated, registering CSS attributes outside Forms assembly is a bit messy, they made everything internal for some reason.
Hi,
I recently upgraded to Xamarin Forms 4.8 and now I see that whenever the application loads it throws the following exception:
If I migrate back to V4.7 the application works as expected.
I have also attached a sample application, which is using Xamarin Forms 4.8, and shows the exception.
Xamarin Forms 4.8 Sample.zip
The text was updated successfully, but these errors were encountered: