1
IDataService(私のWCFデータサービスとのやりとりのためのラッパー)をリセットしようとしていて、SimpleIoc.Defaultに格納されていますコンテキストとそれがどのエンティティをトラッキングしているかを示します。私はコンテナからすべてを削除するResetを使いたくない。 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()を呼び出し、ファクトリメソッドを使用して保存したものを再登録する作業があります。 – Aligned
これは最新のリリースで修正されています。 http://blog.galasoft.ch/archive/2012/06/03/mvvmlight-v4-for-windows-8-rp-is-available.aspxを参照してください。 – LBugnion