Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.Android System.TypeInitializationException:用于';ReactiveUI.ControlFetcherMixin';抛出异常_Xamarin.android_Reactiveui - Fatal编程技术网

Xamarin.Android System.TypeInitializationException:用于';ReactiveUI.ControlFetcherMixin';抛出异常

Xamarin.Android System.TypeInitializationException:用于';ReactiveUI.ControlFetcherMixin';抛出异常,xamarin.android,reactiveui,Xamarin.android,Reactiveui,尝试使用Xamarin.Android+ReactiveUI调用WireUpControls()时,我遇到以下异常 System.TypeInitializationException:的类型初始值设定项 “ReactiveUI.ControlFetcherMixin”引发了异常 + ex {System.TypeInitializationException: The type initializer for 'ReactiveUI.ControlFetcherMixin' th

尝试使用Xamarin.Android+ReactiveUI调用WireUpControls()时,我遇到以下异常

System.TypeInitializationException:的类型初始值设定项 “ReactiveUI.ControlFetcherMixin”引发了异常

+       ex  {System.TypeInitializationException: The type initializer for 'ReactiveUI.ControlFetcherMixin' threw an exception. ---> System.InvalidOperationException: You're using multiple resource ID's with the same name but with different casings which isn't allowed for WireUpControls: { Image = image }, { Text = text }, { Text2 = text2 } ---> System.ArgumentException: An item with the same key has already been added. Key: image
  at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000bb] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] keySelector, System.Func`2[T,TResult] elementSelector, System.Collections.Generic.IEqualityComparer`1[T] comparer) [0x0009e] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0 
  at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] keySelector, System.Func`2[T,TResult] elementSelector) [0x00000] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0 
  at ReactiveUI.ControlFetcherMixin..cctor () [0x00048] in C:\projects\reactiveui\src\ReactiveUI\Android\ControlFetcherMixin.cs:34 
   --- End of inner exception stack trace ---
  at ReactiveUI.ControlFetcherMixin..cctor () [0x0010c] in C:\projects\reactiveui\src\ReactiveUI\Android\ControlFetcherMixin.cs:45 
   --- End of inner exception stack trace ---
我已经检查了以下内容,但仍然得到异常

  • 中定义的控件的命名约定
  • 通过改变解决策略
  • 我在布局中只有一个列表视图

    主要活动:

    protected override void OnCreate(Bundle savedInstanceState)
            {
                base.OnCreate(savedInstanceState);
    
                SetContentView(Resource.Layout.Main);
                this.WireUpControls(ControlFetcherMixin.ResolveStrategy.ExplicitOptIn);
                SetupUserInterface();
    
                this.OneWayBind(ViewModel, x => x.OutletListing, x => x.OutletListItems).DisposeWith(SubscriptionDisposables);
    
            }
    
    更新: 找到了内部异常

    +       ex  {System.TypeInitializationException: The type initializer for 'ReactiveUI.ControlFetcherMixin' threw an exception. ---> System.InvalidOperationException: You're using multiple resource ID's with the same name but with different casings which isn't allowed for WireUpControls: { Image = image }, { Text = text }, { Text2 = text2 } ---> System.ArgumentException: An item with the same key has already been added. Key: image
      at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000bb] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
      at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
      at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] keySelector, System.Func`2[T,TResult] elementSelector, System.Collections.Generic.IEqualityComparer`1[T] comparer) [0x0009e] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0 
      at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] keySelector, System.Func`2[T,TResult] elementSelector) [0x00000] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0 
      at ReactiveUI.ControlFetcherMixin..cctor () [0x00048] in C:\projects\reactiveui\src\ReactiveUI\Android\ControlFetcherMixin.cs:34 
       --- End of inner exception stack trace ---
      at ReactiveUI.ControlFetcherMixin..cctor () [0x0010c] in C:\projects\reactiveui\src\ReactiveUI\Android\ControlFetcherMixin.cs:45 
       --- End of inner exception stack trace ---
    
    +ex{System.TypeInitializationException:'ReactiveUI.ControlFetcherMin'的类型初始值设定项引发了异常。-->System.InvalidOperationException:您使用的多个资源ID具有相同的名称,但具有不同的大小写,这是WireUpControls不允许的:{Image=Image},{Text=Text},{Text2 Text2}-->System.ArgumentException:已添加具有相同键的项。键:图像
    位于System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert(TKey,TValue,System.Collections.Generic.InsertionBehavior)[0x000bb]中:0
    在System.Collections.Generic.Dictionary`2[TKey,TValue].Add(TKey,TValue)[0x00000]中:0
    在System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](System.Collections.Generic.IEnumerable`1[T]源,System.Func`2[T,TResult]键选择器,System.Func`2[T,TResult]元素选择器,System.Collections.Generic.IEqualityComparer`1[T]比较器)[0x0009e]中:0
    位于System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](System.Collections.Generic.IEnumerable`1[T]源,System.Func`2[T,TResult]键选择器,System.Func`2[T,TResult]元素选择器)[0x00000 in:0
    在C:\projects\ReactiveUI\src\ReactiveUI\Android\ControlFetcherMixin.cs中的ReactiveUI.ControlFetcherMixin..cctor()[0x00048]处
    ---内部异常堆栈跟踪的结束---
    在C:\projects\ReactiveUI\src\ReactiveUI\Android\ControlFetcherMixin.cs中的ReactiveUI.ControlFetcherMixin..cctor()[0x0010c]处
    ---内部异常堆栈跟踪的结束---
    
    您的实际异常可能在InnerException中,请特别注意文档中的这一段:

    因为字典是以名称的小写形式编制索引的,所以在不同大小写的布局中不能两次使用相同的资源名称。Android在生成资源ID时区分大小写,因此无法将其映射到单个资源ID以用于WireUpControl


    您可能正在使用多个相似但大小写不同的资源名称。

    我已将Xamarin.Forms项目转换为Xamarin.Android,方法是使Forms PCL具有一些共享类并修改Xamarin.Android目标项目。但我在Xamarin.Android项目中仍然有Xamarin.Forms引用。这会有任何影响吗?