MVVM Light “Type Not Found in cache”

前端 未结 2 371
情书的邮戳
情书的邮戳 2021-01-11 15:44

I\'m trying to convert my Windows Phone 8 Silverlight application to an 8.1 Phone app as part of a universal app. I don\'t know if thats relevant because this is the first t

相关标签:
2条回答
  • 2021-01-11 16:08

    The answer was a fairly simple mistake. This bit was not being executed in design mode

    SimpleIoc.Default.Register<HomePageViewModel>();
    

    My code for SimpleIoc.Default.Register(); was inside an if statement that was never executed in design mode.

    0 讨论(0)
  • 2021-01-11 16:13

    In my case, the target class didn't implement a parameter-less constructor. The only constructor that the class contained accepted a byte type parameter, so I was getting:

    Type not found in cache: System.Byte

    My registration line was like this:

    SimpleIoc.Default.Register<IMyInterface, MyConcreteClass>();
    

    I added a parameter-less constructor to MyConcreteClass and then applied [PreferredConstructor] attribute to it (this attribute is available in GalaSoft.MvvmLight.Ioc namespace) and got rid of the issue.

    Hope this helps someone down the road.

    0 讨论(0)
提交回复
热议问题