lbugnion / mvvmlight

The main purpose of the toolkit is to accelerate the creation and development of MVVM applications in Xamarin.Android, Xamarin.iOS, Xamarin.Forms, Windows 10 UWP, Windows Presentation Foundation (WPF), Silverlight, Windows Phone.
http://www.mvvmlight.net
MIT License
1.17k stars 312 forks source link

Microsoft.Practices.ServiceLocation changed to CommonServiceLocator #28

Open raceybe opened 6 years ago

raceybe commented 6 years ago

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 commented 6 years ago

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 notifications@github.com 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.

CADbloke commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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)

LeiYangGH commented 5 years ago

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 commented 3 years ago

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

image