나는 (내 WCF 데이터 서비스 내 상호 작용에 대한 래퍼입니다) 내가 비울 수 있도록 SimpleIoc.Default에 저장되어있는 내 IDataService를 재설정하기 위해 노력하고있어 작동하지 레지스터 컨텍스트 및 어떤 엔티티가 추적 중인지 확인합니다. 컨테이너에서 모든 것을 제거하는 Reset을 사용하고 싶지 않습니다. 내가 시작할 때 내 IDataService 등록 :이 노력하고있어 SimpleIoc.Default.Register<IDataService, DataService>();
MVVMLight v4.0.21.25721 SimpleIoc 등록 취소 및
,하지만 예상대로 작동하지 않습니다 나는이 예외 받고 있어요 :
{System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at GalaSoft.MvvmLight.Ioc.SimpleIoc.Register[TInterface,TClass](Boolean createInstanceImmediately)
at GalaSoft.MvvmLight.Ioc.SimpleIoc.Register[TInterface,TClass]()
at Bootstrap.ResetDataService()}
public static void ResetDataService()
{
try
{
SimpleIoc.Default.Unregister<IDataService>();
SimpleIoc.Default.Register<IDataService, DataService>();
}
catch (System.Exception)
{
throw;
}
}
감사합니다! SimpleIoc에서 원하는 항목을 가져 와서 Reset()을 호출 한 다음 factory 메소드를 사용하여 저장 한 항목을 다시 등록하는 작업이 있습니다. – Aligned
이것은 최신 릴리스에서 수정되었습니다. http://blog.galasoft.ch/archive/2012/06/03/mvvmlight-v4-for-windows-8-rp-is-available.aspx를 참조하십시오. – LBugnion