Skip to content

NetFxBindingContext

Namespace: Dotsider.Core.Analysis.Models

Assembly: Dotsider.Core.dll

Per-root metadata required to drive a CLR-accurate .NET Framework bind. Built once per analyzed root via AssemblyAnalyzer); carried alongside the analyzer through every resolution surface (Dep Graph, IL navigation, General-tab drill-in, type-forwarder chase) so that every code path produces the same answer for any .NET Framework reference.

public sealed record NetFxBindingContext : IEquatable<NetFxBindingContext>

ObjectNetFxBindingContext

NetFxBindingContext(string, string, string?, string?, NetFxArchitecture, BindingPolicy, IReadOnlyList<string>, IReadOnlyList<string>, NetFxRuntimeVersion, bool)

Section titled “NetFxBindingContext(string, string, string?, string?, NetFxArchitecture, BindingPolicy, IReadOnlyList<string>, IReadOnlyList<string>, NetFxRuntimeVersion, bool)”

Per-root metadata required to drive a CLR-accurate .NET Framework bind. Built once per analyzed root via AssemblyAnalyzer); carried alongside the analyzer through every resolution surface (Dep Graph, IL navigation, General-tab drill-in, type-forwarder chase) so that every code path produces the same answer for any .NET Framework reference.

Parameters:

  • EntryAssemblyPath (String): Path to the root EXE/DLL.
  • AppBaseDirectory (String): Application base — the directory containing the entry assembly.
  • ConfigPath (String): Adjacent *.exe.config/*.dll.config, or null.
  • TargetFramework (String): Target framework moniker (e.g. .NETFramework,Version=v4.8), or null when the root assembly carries no TargetFrameworkAttribute — typical for CLR 2 roots (.NET Framework 2.0 / 3.0 / 3.5), where the runtime version is inferred from the mscorlib assembly reference instead.
  • EffectiveArchitecture (NetFxArchitecture): Runtime process bitness for the root.
  • Policy (BindingPolicy): Layered binding policy (framework unification + machine + publisher + app).
  • PrivatePaths (IReadOnlyList<String>): &lt;probing privatePath&gt; entries from the app config, rooted at AppBaseDirectory.
  • GacRoots (IReadOnlyList<String>): Roots to scan when probing the GAC. Defaults to [%WINDIR%\Microsoft.NET\assembly] for Clr4 and [%WINDIR%\assembly] for Clr2; tests may inject additional roots to exercise publisher-policy discovery without touching the system GAC.
  • RuntimeVersion (NetFxRuntimeVersion): CLR generation the root targets. Drives every per-runtime difference: GAC layout, GAC token format, machine.config path, framework runtime directory, reference-assemblies tree, and appliesTo filtering.
  • IsRuntimeVersionInferred (Boolean): true when RuntimeVersion was determined from the mscorlib assembly reference rather than from a TargetFrameworkAttribute whose value pinned the runtime. Stays true for a CLR 2 root that carries a real .NETFramework,Version=v3.5 TFM (TFM is read but the gate fires on mscorlib v2).
public NetFxBindingContext(string EntryAssemblyPath, string AppBaseDirectory, string? ConfigPath, string? TargetFramework, NetFxArchitecture EffectiveArchitecture, BindingPolicy Policy, IReadOnlyList<string> PrivatePaths, IReadOnlyList<string> GacRoots, NetFxRuntimeVersion RuntimeVersion = NetFxRuntimeVersion.Clr4, bool IsRuntimeVersionInferred = false)

Application base — the directory containing the entry assembly.

Returns: String

public string AppBaseDirectory { get; init; }

Adjacent *.exe.config/*.dll.config, or null.

Returns: String

public string? ConfigPath { get; init; }

Runtime process bitness for the root.

Returns: NetFxArchitecture

public NetFxArchitecture EffectiveArchitecture { get; init; }

Path to the root EXE/DLL.

Returns: String

public string EntryAssemblyPath { get; init; }

Roots to scan when probing the GAC. Defaults to [%WINDIR%\Microsoft.NET\assembly] for Clr4 and [%WINDIR%\assembly] for Clr2; tests may inject additional roots to exercise publisher-policy discovery without touching the system GAC.

Returns: IReadOnlyList<String>

public IReadOnlyList<string> GacRoots { get; init; }

true when RuntimeVersion was determined from the mscorlib assembly reference rather than from a TargetFrameworkAttribute whose value pinned the runtime. Stays true for a CLR 2 root that carries a real .NETFramework,Version=v3.5 TFM (TFM is read but the gate fires on mscorlib v2).

Returns: Boolean

public bool IsRuntimeVersionInferred { get; init; }

Layered binding policy (framework unification + machine + publisher + app).

Returns: BindingPolicy

public BindingPolicy Policy { get; init; }

&lt;probing privatePath&gt; entries from the app config, rooted at AppBaseDirectory.

Returns: IReadOnlyList<String>

public IReadOnlyList<string> PrivatePaths { get; init; }

CLR generation the root targets. Drives every per-runtime difference: GAC layout, GAC token format, machine.config path, framework runtime directory, reference-assemblies tree, and appliesTo filtering.

Returns: NetFxRuntimeVersion

public NetFxRuntimeVersion RuntimeVersion { get; init; }

Target framework moniker (e.g. .NETFramework,Version=v4.8), or null when the root assembly carries no TargetFrameworkAttribute — typical for CLR 2 roots (.NET Framework 2.0 / 3.0 / 3.5), where the runtime version is inferred from the mscorlib assembly reference instead.

Returns: String

public string? TargetFramework { get; init; }

Returns the architecture-correct .NET Framework runtime directory. For Clr4: %WINDIR%\Microsoft.NET\Framework[64]\v4.0.30319. For Clr2: %WINDIR%\Microsoft.NET\Framework[64]\v2.0.50727.

Returns: String

The directory if it exists on disk, otherwise null.

public string? FrameworkRuntimeDirectory()

Returns the GAC sub-directories in the architecture-prioritized scan list. The shape differs by CLR: Clr4: GAC_MSIL + GAC_64 for Amd64, GAC_MSIL + GAC_32 for X86. The bare GAC bucket is reached via LegacyGacScanList for the COM-PIA fallback.Clr2: GAC_MSIL + arch + bare GAC (CLR 1.x carryover, still consulted by CLR2 fusion). All three are scanned with the legacy &lt;version&gt;__&lt;pkt&gt; token format.

Returns: IReadOnlyList<String>

Absolute paths to the GAC sub-directories the binder should scan, in order.

public IReadOnlyList<string> GacScanList()

Returns the legacy CLR 2.0 GAC sub-directories under %WINDIR%\assembly. For Clr4 this is the COM-PIA fallback path probed after the .NET 4 GAC scan misses (e.g. stdole 7.0.3300.0). For Clr2 this returns empty — the primary GacScanList already covers %WINDIR%\assembly directly.

Returns: IReadOnlyList<String>

Absolute paths to scan, in order; empty when not on Windows or for Clr2.

public IReadOnlyList<string> LegacyGacScanList()

Builds a context for a .NET Framework root, or returns null for any other target. .NET Core / .NET 5+ analyzers always receive a null context and fall back to the existing probe chain unchanged.

Parameters:

Returns: NetFxBindingContext

A populated context, or null for non-.NET-Framework roots.

public static NetFxBindingContext? TryBuild(AssemblyAnalyzer rootAnalyzer)