Skip to content
Documentation

Dependency Injection Configuration

The DependencyInjection configuration section allows additional components to be registered with a running PowerTSM application without having to touch or rebuild its source code. Each entry points to a .dll file and names a method inside it. On startup, that method is loaded via reflection and called with the application’s dependency injection container, exactly as if it had been called directly in code.

This is primarily useful for compiled products such as the PowerTSM HTTP API, where no access to the entry point (ITsm.Create()) exists. The method referenced here can call any of the same registration methods (UseCustomFlag, UseTimeSeriesDataStore, etc.) that would otherwise be called directly in code.

HAKOM:DependencyInjection
DependencyInjection
└─ CustomRegistrations
└─ CustomRegistration
└─ {Name}
├─ Name (must repeat {Name})
├─ Assembly
├─ RegistrationMethod
└─ ClassName
<HAKOM>
<DependencyInjection>
<CustomRegistrations>
<CustomRegistration Name="Custom_Data_Store">
<Assembly>MyCompany.CustomDataStore.dll</Assembly>
<RegistrationMethod>UseCustomDataStore</RegistrationMethod>
<ClassName>MyCompany.CustomDataStore.ContainerExtensions</ClassName>
</CustomRegistration>
</CustomRegistrations>
</DependencyInjection>
</HAKOM>

This is equivalent to calling container.UseCustomDataStore() directly in code, where UseCustomDataStore is a public static IContainer UseCustomDataStore(this IContainer container) method defined on the MyCompany.CustomDataStore.ContainerExtensions class inside MyCompany.CustomDataStore.dll.

Each CustomRegistration entry describes one method call.

Path: HAKOM:DependencyInjection:CustomRegistrations:CustomRegistration:{Name}

Element Type Default Required Description
Name string — ✓ A unique identifier for this registration. Used to distinguish entries from each other and referenced in error messages if something goes wrong. Allowed values: any string, unique among all registrations. Example: Custom_Data_Store.
Assembly string — ✓ The path to the .dll file containing the registration method. An absolute path is used as-is; a relative path is resolved the same way HAKOM.xml itself is located (see Where Configuration Files Are Located). Allowed values: an absolute or relative path to a .dll file. Example: MyCompany.CustomDataStore.dll.
ClassName string — ✓ The fully qualified name of a static class in that assembly containing the registration method. Allowed values: a fully qualified class name (namespace and class). Example: MyCompany.CustomDataStore.ContainerExtensions.
RegistrationMethod string — ✓ The name of a public static method on that class. The method must take a single IContainer parameter and nothing else. Allowed values: a method name, without parentheses or parameters. Example: UseCustomDataStore.

A CustomRegistration entry that’s missing any of these settings throws an exception on startup rather than being silently skipped.

The assembly named in Assembly can reference other assemblies of its own. They do not have to be listed anywhere; they are resolved automatically when the registered assembly first needs them:

  1. Assemblies the application already contains (the PowerTSM libraries, .NET itself and every other library the application ships with) are always taken from the application. A registered assembly cannot bring its own version of one of these.

  2. Every other dependency is searched for as {AssemblyName}.dll in the following directories, in this order, including all of their subdirectories:

    • the directory containing the registered assembly
    • the directory of the application
    • %ProgramW6432%\HAKOM and %ProgramFiles(x86)%\HAKOM on Windows, /etc/hakom and /usr/share/hakom on Linux/macOS

    The first directory in which a matching file is found is used. The same applies to the dependencies of those dependencies, so a whole chain of assemblies is resolved without further configuration.

The simplest setup is therefore a dedicated directory that contains the registered assembly together with all of its dependencies.

Since a misconfigured entry can only be detected once the application tries to load and call it, problems in this section surface as exceptions at startup rather than being reported at configuration-parsing time:

Code Exception Situation
HK08015 IncompleteCustomRegistrationException A required setting (Name, Assembly, RegistrationMethod or ClassName) is missing from an entry
HK08016 AssemblyNotFoundException The .dll file named in Assembly cannot be found
HK08017 RegistrationMethodNotFoundException The registration method cannot be found. This is the case if:
- the assembly contains no class with the fully qualified name given in ClassName
- that class is not a static class
- the class has no method named RegistrationMethod
- that method is not public static
- that method does not take exactly one IContainer parameter
HK08020 FailedToLoadAssemblyException The .dll file was found but could not be loaded (e.g. wrong platform, corrupted file)

Multiple CustomRegistration entries can be configured at once, each pointing to a different method call. In XML, each entry is its own <CustomRegistration> element disambiguated by its Name attribute. In JSON and environment variables, which represent configuration as nested key-value pairs rather than XML elements, each registration is keyed directly by its own Name instead. In these two formats, the Name value additionally has to be repeated as its own setting inside each entry, since the key alone is not read as the registration’s name. In XML, the Name attribute already covers this.

<HAKOM>
<DependencyInjection>
<CustomRegistrations>
<CustomRegistration Name="Custom_Data_Store">
<Assembly>MyCompany.CustomDataStore.dll</Assembly>
<RegistrationMethod>UseCustomDataStore</RegistrationMethod>
<ClassName>MyCompany.CustomDataStore.ContainerExtensions</ClassName>
</CustomRegistration>
<CustomRegistration Name="Custom_Flags">
<Assembly>MyCompany.CustomFlags.dll</Assembly>
<RegistrationMethod>UseMyCustomFlags</RegistrationMethod>
<ClassName>MyCompany.CustomFlags.ContainerExtensions</ClassName>
</CustomRegistration>
</CustomRegistrations>
</DependencyInjection>
</HAKOM>
© 2026 Volue.Version v0.6.38017 November 2026