bchavez/Bogus · critical · BogusException

A premium license is required to use this API. Please double

Error message

A premium license is required to use this API. Please double check that your '{LicenseVerifier.LicenseFile}' file exists in the same folder as Bogus.dll. Also, you can add additional probing paths for the license file in {nameof(LicenseVerifier)}.{nameof(LicenseVerifier.ProbePaths)}. Lastly, you can set the following static properties manually: {nameof(Bogus)}.{nameof(License)}.{nameof(License.LicenseTo)} and {nameof(Bogus)}.{nameof(License)}.{nameof(License.LicenseKey)}. For more information, please visit: https://github.com/bchavez/Bogus/wiki/Bogus-Premium

What it means

Thrown by PremiumDataSet when no valid premium license is found. The constructor checks License.LicenseTo/LicenseKey and LicenseVerifier.VerifyLicense; if verification fails it raises a BogusException listing the probing paths and wiki link. Premium data sets (extended locales/features) require a paid license.

Source

Thrown at Source/Bogus/Premium/PremiumDataSet.cs:52

          string.IsNullOrWhiteSpace(License.LicenseKey))
      {
         var path = LicenseVerifier.FindLicense();
         if( path != null )
         {
            LicenseVerifier.ReadLicense(path, out var licenseTo, out var licenseKey);
            License.LicenseTo = licenseTo;
            License.LicenseKey = licenseKey;
         }
      }
      if( !string.IsNullOrWhiteSpace(License.LicenseTo) &&
          !string.IsNullOrWhiteSpace(License.LicenseKey) &&
          LicenseVerifier.VerifyLicense(License.LicenseTo, License.LicenseKey) )
      {
         this.Initialize();
         return;
      }

      throw new BogusException(
         "A premium license is required to use this API. " +
         $"Please double check that your '{LicenseVerifier.LicenseFile}' file exists in the same folder as Bogus.dll. " +
         $"Also, you can add additional probing paths for the license file in {nameof(LicenseVerifier)}.{nameof(LicenseVerifier.ProbePaths)}. " +
         $"Lastly, you can set the following static properties manually: " +
         $"{nameof(Bogus)}.{nameof(License)}.{nameof(License.LicenseTo)} and " +
         $"{nameof(Bogus)}.{nameof(License)}.{nameof(License.LicenseKey)}. "+
         "For more information, please visit: https://github.com/bchavez/Bogus/wiki/Bogus-Premium");
   }


   protected abstract void Initialize();

   protected void LoadResource(Assembly asm, string resourceName)
   {
      var obj = ResourceHelper.ReadBObjectResource(asm, resourceName);
      //patch
      var enLocale = Database.GetLocale("en");

View on GitHub (pinned to 6ece18c5c2)

Solutions

  1. Obtain a premium license and place the license file in the same folder as Bogus.dll (set to copy to output).
  2. Add the license folder to LicenseVerifier.ProbePaths at startup.
  3. Manually set Bogus.License.LicenseTo and Bogus.License.LicenseKey in code before instantiating premium datasets.
  4. If premium is not intended, stop using the premium-only API and use the free dataset equivalents.

Example fix

// before
var data = new SomePremiumDataSet();
// after
Bogus.License.LicenseTo = "MyCo";
Bogus.License.LicenseKey = "...";
var data = new SomePremiumDataSet();
Defensive patterns

Strategy: validation

Validate before calling

// verify license presence before touching premium APIs
if (!LicenseVerifier.VerifyLicense(Bogus.License.LicenseTo, Bogus.License.LicenseKey))
    throw new InvalidOperationException("Premium license missing or invalid");

Try / catch

try { var ds = new SomePremiumDataSet(); }
catch (BogusException ex) when (ex.Message.Contains("premium license")) {
    // load license from vault/secrets and set License.LicenseTo/Key, then retry or disable feature
}

Prevention

When it happens

Trigger: Instantiating any PremiumDataSet subclass (e.g. premium locale data) without a valid license file next to Bogus.dll or without manually setting License.LicenseTo/LicenseKey.

Common situations: Using premium-only API surface in CI/deployment where the license file is missing, or after a Bogus upgrade that changed license probing. License file not copied to output directory.

Related errors


AI-assisted analysis of bchavez/Bogus@6ece18c5c2 (2026-08-13). Data as JSON: /api/errors/141ac3a772a0ffa9. Report an issue: GitHub.