mvvmlight icon indicating copy to clipboard operation
mvvmlight copied to clipboard

Microsoft.Practices.ServiceLocation changed to CommonServiceLocator

Open raceybe opened this issue 8 years ago • 11 comments

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?

raceybe avatar Mar 25 '18 00:03 raceybe

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://mvvmlhttp://mvvmlughtight.net/std10

Let me know if that doesn't work for you.

Thanks Laurent

Laurent Bugnion, Microsoft- +41 79 537 78 08


From: raceybe [email protected] Sent: Sunday, March 25, 2018 01:53 To: lbugnion/mvvmlight Cc: Subscribed Subject: [lbugnion/mvvmlight] Microsoft.Practices.ServiceLocation changed to CommonServiceLocator (#28)

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?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/lbugnion/mvvmlight/issues/28, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEscWcW7cXdO8MO2_vFvjsLnmYmOzrm1ks5thuqGgaJpZM4S59sj.

lbugnion avatar Mar 26 '18 17:03 lbugnion

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

CADbloke avatar May 01 '18 03:05 CADbloke

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 avatar Nov 28 '18 17:11 RetrotecEd

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"

RetrotecEd avatar Nov 28 '18 17:11 RetrotecEd

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.

aardila avatar Dec 13 '18 14:12 aardila

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.

H97-Git avatar Feb 06 '19 17:02 H97-Git

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;```

MrEmanuel avatar Feb 20 '19 13:02 MrEmanuel

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.

H97-Git avatar Feb 21 '19 11:02 H97-Git

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 (https://github.com/unitycontainer/commonservicelocator/commit/908a30f0f4c036d1ded0c0967fa3a7ae823aa5ce#diff-af172358836574e0cedcd1939bd9092b)

jamesmcroft avatar Mar 18 '19 23:03 jamesmcroft

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.

LeiYangGH avatar Jun 28 '19 07:06 LeiYangGH

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

image

sebastiankozub avatar Sep 13 '20 14:09 sebastiankozub