{"record":{"id":"539d0322dfbe6f93","repo":"chocolatey/choco","slug":"unable-to-load-licensed-assembly","errorCode":null,"errorMessage":"Unable to load licensed assembly.","messagePattern":"Unable to load licensed assembly\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure/licensing/License.cs","lineNumber":43,"sourceCode":"    public static class License\r\n    {\r\n        public static ChocolateyLicense ValidateLicense()\r\n        {\r\n            var license = LicenseValidation.Validate();\r\n            if (license.IsLicensedVersion())\r\n            {\r\n                try\r\n                {\r\n#if FORCE_CHOCOLATEY_OFFICIAL_KEY\r\n                    var chocolateyPublicKey = ApplicationParameters.OfficialChocolateyPublicKey;\r\n#else\r\n                    var chocolateyPublicKey = ApplicationParameters.UnofficialChocolateyPublicKey;\r\n#endif\r\n                    var licensedAssembly = AssemblyResolution.LoadExtension(ApplicationParameters.LicensedChocolateyAssemblySimpleName);\r\n\r\n                    if (licensedAssembly == null)\r\n                    {\r\n                        throw new ApplicationException(\"Unable to load licensed assembly.\");\r\n                    }\r\n\r\n                    license.AssemblyLoaded = true;\r\n                    license.Assembly = licensedAssembly;\r\n                    license.Version = VersionInformation.GetCurrentInformationalVersion(licensedAssembly);\r\n\r\n                    // The licensed assembly is installed, check its supported Chocolatey versions and/or the assembly\r\n                    // version so we can attempt to determine whether it's compatible with this version of Chocolatey.\r\n                    var minimumChocolateyVersionString = VersionInformation.GetMinimumChocolateyVersion(licensedAssembly);\r\n                    \"chocolatey\".Log().Debug(\"Minimum Chocolatey Version: '{0}'\".FormatWith(minimumChocolateyVersionString));\r\n                    var currentChocolateyVersionString = VersionInformation.GetCurrentAssemblyVersion();\r\n                    \"chocolatey\".Log().Debug(\"Current Chocolatey Version: '{0}'\".FormatWith(currentChocolateyVersionString));\r\n                    var currentChocolateyLicensedVersionString = VersionInformation.GetCurrentAssemblyVersion(licensedAssembly);\r\n                    \"chocolatey\".Log().Debug(\"Current Chocolatey Licensed Version: '{0}'\".FormatWith(currentChocolateyLicensedVersionString));\r\n\r\n                    var minimumChocolateyVersion = new Version(minimumChocolateyVersionString);\r\n                    var currentChocolateyVersion = new Version(currentChocolateyVersionString);\r\n                    var currentChocolateyLicensedVersion = new Version(currentChocolateyLicensedVersionString);\r","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure/licensing/License.cs#L25-L61","documentation":"Thrown by License loading when AssemblyResolution.LoadExtension returns null for the licensed Chocolatey assembly (chocolatey.licensed). The licensed extension assembly could not be located or loaded by the extension loader, so license construction aborts before any version-compatibility checks run.","triggerScenarios":"Chocolatey attempts to load its commercial/licensed extension (typically chocolatey.licensed.dll) and the resolution returns null - the assembly is absent from the extensions directory, has the wrong strong-name/public key, or failed to load due to a dependency mismatch.","commonSituations":"A licensed Chocolatey install where the licensed package was not installed/upgraded, a public-key mismatch between official and unofficial builds (controlled by FORCE_CHOCOLATEY_OFFICIAL_KEY), a .NET runtime/dependency incompatibility breaking assembly load, or a corrupted extensions folder.","solutions":["Install or reinstall the licensed package: choco install chocolatey.extension (or the appropriate licensed extension package).","Verify the build matches the key flavor - unofficial builds cannot load officially-signed licensed assemblies and vice versa; rebuild/reinstall the matching flavor.","Check the Chocolatey log for the inner load failure (dependency not found, BadImageFormatException) and resolve that dependency.","Confirm the extensions directory contains the expected chocolatey.licensed.dll and is not corrupted."],"exampleFix":"// before: missing/old extension\nchoco upgrade chocolatey -y  // licensed.dll never installed\n\n// after\nchoco upgrade chocolatey.extension -y\nchoco upgrade chocolatey -y","handlingStrategy":"try-catch","validationCode":"var extDir = Environment.GetEnvironmentVariable(\"ChocolateyInstall\") is string ci\n    ? System.IO.Path.Combine(ci, \"extensions\")\n    : System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, \"extensions\");\nif (!System.IO.Directory.EnumerateFiles(extDir, \"chocolatey.licensed.dll\", SearchOption.AllDirectories).Any())\n    throw new InvalidOperationException(\"chocolatey.licensed assembly not found. Install/upgrade the licensed extension package.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    license = License.LoadLicense();\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"Unable to load licensed assembly\"))\n{\n    logger.Warn(ex.Message + \" Licensed features disabled. Install chocolatey.extension or check build key flavor.\");\n}","preventionTips":["Keep the licensed extension package installed and version-aligned with the Chocolatey build.","Match the build's public-key flavor (official vs unofficial) so the licensed assembly is accepted.","Make the licensed-extension load failure non-fatal in calling code so FOSS features keep working."],"tags":["licensing","assembly-load","extension","runtime-dependency"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}