CodeBrix.ServiceLocator.MsplLicenseForever 1.0.251.1433

dotnet add package CodeBrix.ServiceLocator.MsplLicenseForever --version 1.0.251.1433
                    
NuGet\Install-Package CodeBrix.ServiceLocator.MsplLicenseForever -Version 1.0.251.1433
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodeBrix.ServiceLocator.MsplLicenseForever" Version="1.0.251.1433" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeBrix.ServiceLocator.MsplLicenseForever" Version="1.0.251.1433" />
                    
Directory.Packages.props
<PackageReference Include="CodeBrix.ServiceLocator.MsplLicenseForever" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CodeBrix.ServiceLocator.MsplLicenseForever --version 1.0.251.1433
                    
#r "nuget: CodeBrix.ServiceLocator.MsplLicenseForever, 1.0.251.1433"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CodeBrix.ServiceLocator.MsplLicenseForever@1.0.251.1433
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CodeBrix.ServiceLocator.MsplLicenseForever&version=1.0.251.1433
                    
Install as a Cake Addin
#tool nuget:?package=CodeBrix.ServiceLocator.MsplLicenseForever&version=1.0.251.1433
                    
Install as a Cake Tool

CodeBrix.ServiceLocator

A fully managed service-location abstraction library for .NET. It provides a shared interface over IoC containers and service locators, so an application can resolve services indirectly — by type, or by type plus a string key — without taking a hard reference on any specific container. The library is the abstraction only: it contains no container of its own, performs no registration and creates no objects; you supply a container adapter, and this library defines the shape that adapter presents to the rest of the application.

CodeBrix.ServiceLocator has no dependencies other than .NET, and is provided as a .NET Standard 2.0 / .NET 10 library and associated CodeBrix.ServiceLocator.MsplLicenseForever NuGet package.

CodeBrix.ServiceLocator supports applications and assemblies that target Microsoft .NET version 10.0 and later, and — via its .NET Standard 2.0 target — downlevel consumers such as Roslyn source generators and analyzers. Microsoft .NET version 10.0 is a Long-Term Supported (LTS) version of .NET, and was released on Nov 11, 2025; and will be actively supported by Microsoft until Nov 14, 2028. Please update your C#/.NET code and projects to the latest LTS version of Microsoft .NET.

Installation

dotnet add package CodeBrix.ServiceLocator.MsplLicenseForever

Note that the NuGet package ID and the namespace are different - there is no package named plain CodeBrix.ServiceLocation:

  • NuGet package ID: CodeBrix.ServiceLocator.MsplLicenseForever
  • Assembly: CodeBrix.ServiceLocator
  • Primary namespace: CodeBrix.ServiceLocation - i.e. using CodeBrix.ServiceLocation;

Read that difference carefully — it is the one thing that most often goes wrong here. The package ID and the assembly end in ServiceLocator, while the namespace you write in a using directive ends in ServiceLocation. using CodeBrix.ServiceLocator; does not compile — it fails with CS0246, because no namespace of that name exists.

The namespace is spelled that way deliberately. A namespace named CodeBrix.ServiceLocator would be a member of the enclosing CodeBrix namespace, so in any consumer whose own namespace begins with CodeBrix. the bare name ServiceLocator would bind to the namespace and hide the class of the same name. With CodeBrix.ServiceLocation, ServiceLocator.Current resolves correctly from any namespace.

The library has no NuGet dependencies — it uses only the .NET base class library — and there are no native assets and no platform restrictions. XML documentation (IntelliSense) ships alongside the assembly.

CodeBrix.ServiceLocator supports:

  • IServiceLocator — the shared abstraction for resolving services by type or by type + name, including GetInstance, GetInstance<TService>, GetAllInstances, and GetAllInstances<TService>. It extends System.IServiceProvider.
  • ServiceLocator — a static ambient-container accessor (ServiceLocator.Current, ServiceLocator.SetLocatorProvider, ServiceLocator.IsLocationProviderSet).
  • ServiceLocatorImplBase — an abstract base that implements the full IServiceLocator surface in terms of two DoGetInstance / DoGetAllInstances template methods, so a container adapter only needs to implement two methods.
  • ActivationException — the standard exception raised when service resolution fails (resolution errors thrown by the underlying container are wrapped in it).
  • ServiceLocatorProvider — the delegate used to supply the ambient container to ServiceLocator.

Sample Code

Implement a container adapter and use the ambient accessor

using System;
using System.Collections.Generic;
using CodeBrix.ServiceLocation;

// 1. Adapt your IoC container by deriving from ServiceLocatorImplBase.
public sealed class MyContainerAdapter : ServiceLocatorImplBase
{
    private readonly IMyContainer _container;

    public MyContainerAdapter(IMyContainer container)
    {
        _container = container;
    }

    protected override object DoGetInstance(Type serviceType, string key)
    {
        // Resolve a single service from your container.
        return _container.Resolve(serviceType, key);
    }

    protected override IEnumerable<object> DoGetAllInstances(Type serviceType)
    {
        // Resolve all registered services of serviceType.
        return _container.ResolveAll(serviceType);
    }
}

// 2. Register the adapter as the ambient container, once, at startup.
//    Create the adapter ONCE and have the provider hand back that same
//    instance: the delegate is invoked on every read of ServiceLocator.Current,
//    so `() => new MyContainerAdapter(...)` would build a new adapter on every
//    single resolution.
var locator = new MyContainerAdapter(myContainer);
ServiceLocator.SetLocatorProvider(() => locator);

// 3. Resolve services anywhere via the ambient accessor.
var service = ServiceLocator.Current.GetInstance<IMyService>();
var named = ServiceLocator.Current.GetInstance<IMyService>("secondary");
var all = ServiceLocator.Current.GetAllInstances<IMyService>();

Clear the ambient container

using CodeBrix.ServiceLocation;

// The provider is process-wide static state. Tests, and applications that
// tear down and rebuild their container, should clear it explicitly.
ServiceLocator.SetLocatorProvider(null);

if (!ServiceLocator.IsLocationProviderSet)
{
    // ServiceLocator.Current would now throw InvalidOperationException.
}

Documentation

The NuGet package includes AGENT-README.txt, a complete API reference and usage guide written for AI coding agents - point your agent at that file when it is writing code against this library.

Additional sample code and usage examples are available in the CodeBrix.ServiceLocator.Tests project: https://github.com/ellisnet/CodeBrix.ServiceLocator/tree/main/tests/CodeBrix.ServiceLocator.Tests

License

CodeBrix.ServiceLocator is licensed under the Microsoft Public License (Ms-PL) - see the LICENSE file.

For licensing and provenance information about the open source code included in this package, see THIRD-PARTY-NOTICES.txt.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on CodeBrix.ServiceLocator.MsplLicenseForever:

Package Downloads
CodeBrix.Platform.ApacheLicenseForever

The core CodeBrix.Platform UI package for desktop apps (C# and XAML on .NET 10 / Skia). Self-contained: bundles the CodeBrix.Platform Foundation, WinRT, Dispatching and Foundation.Logging assemblies.

CodeBrix.Platform.Extensions.ApacheLicenseForever

A .NET Standard 2.0 and .NET 10 bundle of the core nventive Uno.Core.Extensions helper libraries (general extensions, collections, disposables, equality, logging, and threading), namespace-renamed into CodeBrix.Platform.Extensions.* for use by CodeBrix.Platform and its consumers. Multi-targets netstandard2.0 (e.g. for Roslyn source generators) and net10.0. Vendors the source of Uno.Core.Extensions, .Collections, .Disposables, .Equality, .Logging, .Logging.Singleton, and .Threading at version 4.1.1.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.251.1433 41 9/8/2026
1.0.242.1047 284 8/30/2026