locked
ServiceLocator & NETStandard.Library (2.0.0) - SimpleIoc.Default not valid RRS feed

  • Question

  • User355271 posted

    I am working on a new App with .Net Core, and when I try to implement my "Bootstrap application" (a basic app with some core functions) I get stuck when trying to set the ServiceLocator ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

    I get the following errors: * Cannot implicitly convert type 'GalaSoft.MvvmLight.Ioc.SimpleIoc' to 'CommonServiceLocator.IServiceLocator'. An explicit conversion exists (are you missing a cast?) (CS0266) (Mobile) * The type 'IServiceLocator' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. (CS0012) (Mobile)

    I tried adding the assembly 'Microsoft.Practices.ServiceLocation' but it has no compatibility NETStandard.Library (2.0.0)

    Any idea how to solve this ? Thanks in advance !

    Friday, October 27, 2017 4:30 PM

Answers

  • User355271 posted

    After some more research I found an article from the author of MvvmLight explaining how to use MvvmLight with NETStandard 1.0. (I don't have the rights to post links yet) I had ignored it at first since I am trying to use 2.0 The article explains where the error I was facing came from.

    In MVVM Light for .NET Standard 1.0, I decided to remove this dependency completely. As a result, it means that the ServiceLocator class is not available anymore. In the rest of the code, you need to remove every mention to ServiceLocator.Current and replace with SimpleIoc.Default

    Anyway, after some fiddling with dependencies and obsolete code, everything works as expected

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, October 30, 2017 12:38 PM

All replies

  • User355271 posted

    After some more research I found an article from the author of MvvmLight explaining how to use MvvmLight with NETStandard 1.0. (I don't have the rights to post links yet) I had ignored it at first since I am trying to use 2.0 The article explains where the error I was facing came from.

    In MVVM Light for .NET Standard 1.0, I decided to remove this dependency completely. As a result, it means that the ServiceLocator class is not available anymore. In the rest of the code, you need to remove every mention to ServiceLocator.Current and replace with SimpleIoc.Default

    Anyway, after some fiddling with dependencies and obsolete code, everything works as expected

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, October 30, 2017 12:38 PM
  • User271113 posted

    Hi Theo ! I faced with the same issue, but I cannot understand what to do with this error. Have you removed this line ? : ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); What NuGet have you used ? For me - CommonServiceLocator 2.1.0 - MvvmLightLibsStd10 5.4.0.1-alpha

    Wednesday, November 22, 2017 1:04 PM
  • User271113 posted

    Ok I found the link I needed. Just remove the line with ServiceLocator and use directly the SimpleIoC class :smile:

    Wednesday, November 22, 2017 1:13 PM