0

我試圖使我們的應用程序兼容mvvm。目前所有的代碼都是在後面的代碼中編寫的。我決定使用SimpleIOC和MVVM Light。但由於某種原因,只是不想工作。我在檔案111上運行。我註冊了我的類和接口。當我試圖解決它們時,這是我得到這個異常的例外。任何指針?無法讓IOC以Xamarin格式工作

System.Reflection.TargetInvocationException:調用的目標引發了異常。 ---> Microsoft.Practices.ServiceLocation.ActivationException:在緩存中找不到類型:CustomerApp.Service.RestClient.IApiClient。在D:\ GalaSoft \ mydotnet \ MVVMLight \ source \ GalaSoft.MvvmLight \ GalaSoft.MvvmLight中的GalaSoft.MvvmLight.Ioc.SimpleIoc.DoGetService(System.Type serviceType,System.String key,System.Boolean緩存)[0x0003f]處的 。在D:\ GalaSoft \ mydotnet \ MVVMLight \ source \ GalaSoft.MvvmLight \ GalaSoft中GalaSoft.MvvmLight.Ioc.SimpleIoc.GetService(System.Type serviceType)[0x00000]處的附加程序(PCL)\ Ioc \ SimpleIoc.cs:537 。 D:\ GalaSoft \ mydotnet \ MVVMLight \ source \ GalaSoft.MvvmLight \ GalaSoft中的GalaSoft.MvvmLight.Ioc.SimpleIoc.MakeInstance [TClass]()[0x00064]中的MvvmLight.Extras(PCL)\ Ioc \ SimpleIoc.cs:789 .MvvmLight.Extras(PCL)\ Ioc \ SimpleIoc.cs:729 at(wrapper managed-to-native)System.Reflection.MonoMethod:InternalInvoke(System.Reflection.MonoMethod,object,object [],System.Exception &) at System.Reflection.MonoMethod.Invoke(System.Ob在/ Users/builder/data/lanes/3819/c1d1c79c/source /目錄中的[0x00038] ject obj,System.Reflection.BindingFlags invokeAttr,System.Reflection.Binder聯編程序,System.Object []參數,System.Globalization.CultureInfo culture) mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:305 ---內部異常堆棧跟蹤結束--- at System.Reflection.MonoMethod.Invoke(System.Object obj,System.Reflection.BindingFlags在/ Users/builder/data/lanes/3819/c1d1c79c/source/mono/mcs/class/corlib/system目錄中的[0x00050] System.Reflection/MonoMethod.cs:313 at System.Reflection.MethodBase.Invoke(System.Object obj,System.Object [] parameters)[0x00000] in/Users/builder/data/lanes/3819/c1d1c79c/source/mono/mcs/class/referencesource/mscorlib/system/reflection/methodbase.cs:229 at System .Delegate.DynamicInvokeImpl(System.Object [] args)在/Users/builder/data/lanes/3819/c1d1c79c/source/mono/mcs/class/corlib/System/Delegate.cs:461 System上的[0x00107]。 MulticastDelegate.DynamicInvokeImpl(System.Object [] args)/Users/builder/data/lanes/3819/c1d1c79c/source/mono/mcs/class/corlib/System/MulticastDelegate.cs:67 System.Delegate中的[0x0000b] .DynamicInvoke(System.Object [] args)/Users/builder/data/lanes/3819/c1d1c79c/source/mono/mcs/class/corlib/System/Delegate.cs:406 GalaSoft.MvvmLight中的[0x00000]。 D:\ GalaSoft \ mydotnet \ MVVMLight \ source \ GalaSoft.MvvmLight \ GalaSoft.MvvmLight.Extras(PCL)\ Ioc中的Ioc.SimpleIoc.DoGetService(System.Type serviceType,System.String key,System.Boolean緩存)[0x000c9] \ SimpleIoc.cs:567 at GalaSoft.MvvmLight.Ioc.SimpleIoc.GetInstance [TService]()[0x00000] in D:\ GalaSoft \ mydotnet \ MVVMLight \ source \ GalaSoft.MvvmLight \ Gal在C:\ Xamarin Backup \ CustomerApp \ CustomerApp \ CustomerApp \ App.xaml.cs中的CustomerApp.App..ctor()[0x00016]處的aSoft.MvvmLight.Extras(PCL)\ Ioc \ SimpleIoc.cs:912 :29

+2

發佈您的代碼的相關部分總是一個好主意。單獨的堆棧跟蹤沒有那麼有用 – Jason

+0

您在哪裏註冊您的IoC容器? – valdetero

+0

我想SimpleIOC ....並不那麼簡單。 – Will

回答

1

我將我的配置文件更改爲259並添加了Microsoft http客戶端nuget。這似乎是竅門