Portable version to support all platforms


Posted as discussion by onovotny: http://commonservicelocator.codeplex.com/discussions/347703.
I wanted to propose using the new VS 11 Portable libraries to enable a single instance of the CommonServiceLocator to work with .NET 4, SL4+, WP7.1+, WinRT and XBox 360.
The only breaking change is that IServiceProvider has been removed from WinRT and so isn't available for portable libraries. From an API perspective, in my test build, I simply moved the single GetService method to the IServiceLocator interface instead.
Between using it as a Portable Library and the removal of IServiceProivder, the changes would warrant a version bump to 2.0 to prevent accidental conflicts. If you can get that built and put on to NuGet, it would enable you to have a single binary that all platforms can reference.


MichaelKetting wrote Aug 24, 2012 at 1:38 PM

Removing IServiceProvider would also solve the conundrum of how to throw/not throw on GetService.

Regards, Michael

onovotny wrote Oct 6, 2012 at 6:56 PM

The new PCL version is missing the NeutralResourcesLanguageAttribute. That's generating a compiler warning:

Warning 1 The assembly "C:\Users\Public\Downloads\CodePlex\MVVMLight\GalaSoft.MvvmLight\Portable\packages\Portable.CommonServiceLocator.1.2\lib\portable-net4+sl4+wp7+win8\Microsoft.Practices.ServiceLocation.dll" does not have a NeutralResourcesLanguageAttribute on it. To be used in an app package, portable libraries must define a NeutralResourcesLanguageAttribute on their main assembly (ie, the one containing code, not a satellite assembly). C:\Users\Public\Downloads\CodePlex\MVVMLight\GalaSoft.MvvmLight\Portable\packages\Portable.CommonServiceLocator.1.2\lib\portable-net4+sl4+wp7+win8\Microsoft.Practices.ServiceLocation.dll GalaSoft.MvvmLight.Test.Portable.WinRT

Can you please add the attribute and re-release the PCL binary?


tillig wrote Dec 3, 2012 at 5:17 PM

It appears this has been released for download but isn't in the official CommonServiceLocator NuGet package. Is there a plan to update the package and include the portable version?