Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Microsoft.Practices.ServiceLocation changed to CommonServiceLocator #28

Open
raceybe opened this issue Mar 25, 2018 · 11 comments
Open

Microsoft.Practices.ServiceLocation changed to CommonServiceLocator #28

raceybe opened this issue Mar 25, 2018 · 11 comments

Comments

@raceybe
Copy link

raceybe commented Mar 25, 2018

I don't know if this is a real issue or not, since I am completely new to mvvmlight.

The New Project template references Microsoft.Practices.ServiceLocation whereas the updated CommonServiceLocator assembly is called just that. It appears that the assembly was renamed for version 2.0.0+?

Can the New Project template for mvvmlight be updated to reflect this?

@lbugnion
Copy link
Owner

lbugnion commented Mar 26, 2018 via email

@CADbloke
Copy link

CADbloke commented May 1, 2018

Updating <package id="MvvmLight" version="5.3.0.0" targetFramework="net45" /> to <package id="MvvmLight" version="5.4.1" targetFramework="net46" /> broke my app : The type or namespace name 'Practices' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

It failed to update the CommonServiceLocator dependency. Even manually updating that dependency did not fix it

@RetrotecEd
Copy link

RetrotecEd commented Nov 28, 2018

Any update on this? I just tried adding MVVMLight to a brand new WPF app in Visual Studio 2017 - updated the nuget packages to the latest release:

Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'Practices' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?

@RetrotecEd
Copy link

RetrotecEd commented Nov 28, 2018

Packages I have:

package id="CommonServiceLocator" version="2.0.4" targetFramework="net471"
package id="MvvmLight" version="5.4.1.1" targetFramework="net471"
package id="MvvmLightLibs" version="5.4.1.1" targetFramework="net471"

@aardila
Copy link

aardila commented Dec 13, 2018

Hi, Until. I publish a new template, the process is to update to the new MVVM Light Libs version and to fix the compilation errors according to Http://mvvmlight.net/std10 Let me know if that doesn't work for you. Thanks Laurent Laurent Bugnion, Microsoft- +41 79 537 78 08

This is doesn't just happen with the template though. This happens on any project to which the nuget MvvmLight package is installed, not just the [...]LibsStd10 packages as per the link. I just installed the latest stable version (5.4.1.1 at writing) of the MvvmLight package from nuget to an existing WPF project and had the same error come up as the OP. I could only get the project to compile by downgrading the CommonServiceLocator dependency package to version to 1.3.0 as described in this MSDN forum post.

@H97-Git
Copy link

H97-Git commented Feb 6, 2019

This is doesn't just happen with the template though. This happens on any project to which the nuget MvvmLight package is installed, not just the [...]LibsStd10 packages as per the link. I just installed the latest stable version (5.4.1.1 at writing) of the MvvmLight package from nuget to an existing WPF project and had the same error come up as the OP. I could only get the project to compile by downgrading the CommonServiceLocator dependency package to version to 1.3.0 as described in this MSDN forum post.

Ty this worked for me for the same issue.

@MrEmanuel
Copy link

MrEmanuel commented Feb 20, 2019

I'm new to C# and MVVM Light. I just started a new project with MVVMLight and I fixed the error by using CommonServiceLocator which seem to include 'ServiceLocator'.

Here are my dependecies in the file ViewModelLocaltor.cs

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;  // This is not used
using CommonServiceLocator;```

@H97-Git
Copy link

H97-Git commented Feb 21, 2019

I'm new to C# and MVVM Light. I just started a new project with MVVMLight and I fixed the error by using CommonServiceLocator which seem to include 'ServiceLocator'.

Here are my dependecies in the file ViewModelLocaltor.cs

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;  // This is not used
using CommonServiceLocator;```
  1. You can try the STD10 version of MvvMLight (Uninstall MvvmLight (and libs (should be auto)), then reinstall MvvmLightSTD10 (Search for "MvvmLightStd10" instead of "MvvmLight")

2.You can try to downgrade(Uninstall , Reinstall) MvvMLight and dependencies (Libs and CommonServiceLocator) for something like MvvMLight 5.3.0 and CommonServiceLocator 1.3.0 like this post

3.You can search for an alternative to MvvmLight (React , MvvmCross, Prism), I recommend MvvmCross wich seems to have more docs (very useful for beginner don't be afraid of it) and more community support, Pls correct me if I'm wrong for this last point.

@jamesmcroft
Copy link

This was a breaking change in the CommonServiceLocator package in an incremental version and isn't particularly an issue with MvvmLight.

The fix for this is to change your using statements from:

using Microsoft.Practices.ServiceLocation;

to

using CommonServiceLocator;

This will fix the problems. You can find more information on this change in the CommonServiceLocator change history (unitycontainer/commonservicelocator@908a30f#diff-af172358836574e0cedcd1939bd9092b)

@LeiYangGH
Copy link

I'm still facing this issue. Steps:

  1. Use VS2019, create a .net4.5 WPF project
  2. Install mvvmlight 5.4.1.1, compile staill failed.

@sebastiankozub
Copy link

sebastiankozub commented Sep 13, 2020

Till now works fine but have not used all MVVM toolkits ;-) .NET Core 3.1 and newest other packages:

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants