RegistryLinkedList 1.0.0

dotnet add package RegistryLinkedList --version 1.0.0
                    
NuGet\Install-Package RegistryLinkedList -Version 1.0.0
                    
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="RegistryLinkedList" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RegistryLinkedList" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RegistryLinkedList" />
                    
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 RegistryLinkedList --version 1.0.0
                    
#r "nuget: RegistryLinkedList, 1.0.0"
                    
#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 RegistryLinkedList@1.0.0
                    
#: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=RegistryLinkedList&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RegistryLinkedList&version=1.0.0
                    
Install as a Cake Tool

RegistryLinkedList

RegistryLinkedList is a simple IList<T>-like collection that stores unmanaged numeric values in the Windows Registry as a single binary value. The collection keeps an in-memory cache and watches the registry key for external changes; local modifications are persisted back to the registry and external changes refresh the cache and raise a notification.

Requirements

  • Windows (uses Microsoft.Win32.Registry)
  • .NET Framework 4.8, .NET 6 or .NET 8

Installation

  1. Build the project and reference the resulting assembly in your solution, or add the project to your solution.

  2. Add the required namespaces:

    using Microsoft.Win32;
    using PhoenixTools.Registry;
    

Quick start

Create a list that stores 32-bit integers under HKCU:\Software\MyApp\MyList in a value named "Values":

using var list = new RegistryLinkedList<int>(RegistryHive.CurrentUser, "Software\\MyApp\\MyList", "Values");

list.Add(10);
list.Add(20);
Console.WriteLine($"Count = {list.Count}");

foreach (var v in list)
    Console.WriteLine(v);

Listening for external changes

The collection exposes a ListChanged event which is raised after local updates or when the registry value is modified by another process.

using var list = new RegistryLinkedList<long>(RegistryHive.CurrentUser, "Software\\MyApp\\MyList", "Values");

list.ListChanged += (s, e) =>
{
    Console.WriteLine("Registry-backed list changed (local or external).");
};

list.Add(12345); // will trigger ListChanged

Supported operations

RegistryLinkedList<T> implements IList<T> and supports the usual operations:

  • Add(item)
  • Remove(item)
  • Clear()
  • Insert(index, item)
  • RemoveAt(index)
  • IndexOf(item), Contains(item), CopyTo(array, index)
  • Count, IsReadOnly

Supported generic types

T must be an unmanaged numeric type. Typical supported types include:

  • byte, sbyte, short, ushort, int, uint, long, ulong, float, double

(The implementation serializes raw binary representations of values; make sure the chosen type matches your intentions.)

Behavior and limitations

  • Values are serialized into a single REG_BINARY under the provided value name.
  • The collection maintains an in-memory cache for performance and synchronizes it with registry storage on changes.
  • There is no transaction or advanced concurrency control: updates overwrite the entire binary blob.
  • Required registry permissions depend on the hive and key; operations may throw security-related exceptions if permissions are insufficient.

Error handling

  • Constructor will throw ArgumentNullException if key or storage arguments are null or whitespace.
  • InvalidDataException may be thrown if existing registry content has an unexpected format.

Recommendations

  • Always dispose the RegistryLinkedList (use using) so the internal registry watcher is stopped and unsubscribed.
  • Subscribe to ListChanged if your application must react to changes made by other processes.
  • Prefer fixed-width numeric types (e.g., int, long) for predictable binary layout across runtimes.

Example use case

Store a short run history across application instances so new instances can observe previous run identifiers:

using var runs = new RegistryLinkedList<int>(RegistryHive.CurrentUser, "Software\\MyApp\\RunIds", "RunIds");
runs.Add(Environment.TickCount);

License

MIT license.

Support

Open an issue in the repository for questions or bug reports.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 91 8/30/2026

Initial release