2017-11-24 18 views
0

Xamarin.Android + ReactiveUI로 WireUpControls()를 호출 할 때 다음 예외가 발생합니다.Xamarin.Android System.TypeInitializationException : 'ReactiveUI.ControlFetcherMixin'의 형식 이니셜 라이저에서 예외가 발생했습니다.

System.TypeInitializationException : 'ReactiveUI.ControlFetcherMixin'의 형식 이니셜 나는 다음하지만 난 여전히 예외를 받고 있어요 확인했습니다

에서 예외가 발생했습니다. 해석 처리 전략을 변경

  • https://reactiveui.net/docs/handbook/data-binding/xamarin-android/wire-up-controls에 기재된 컨트롤

    1. 명명 규칙.

    레이아웃에 ListView 만 있습니다.

    주요 활동 :

    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 --- 
    
  • +0

    Forms PCL을 공유 클래스로 만들고 Xamarin.Android 대상 프로젝트를 수정하여 Xamarin.Forms 프로젝트를 Xamarin.Android로 변환했습니다. 하지만 저는 여전히 Xamarin을 가지고 있습니다. Xamarin. 그게 효과가 있을까요? –

    답변

    1

    귀하의 실제 예외가의 InnerException 아마 인 내부 예외, 문서에서이 구절에 특별히주의 :

    사전은 이름의 소문자 변형으로 색인화되기 때문에 다른 외피를 사용하는 레이아웃에서 동일한 자원 이름을 두 번 사용할 수 없습니다. Android는 리소스 ID를 생성 할 때 대/소문자를 구분하므로 WireUpControls와 함께 사용할 단일 리소스 ID에 매핑 할 수 있습니다.

    아마도 서로 비슷하지만 대소 문자가 다른 여러 개의 자원 이름을 사용하고있을 것입니다.