title: How to use Microsoft.AspNetCore.DataProtection in the console application?
body: <p>On the page <a href="https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/non-di-scenarios?view=aspnetcore-3.1" rel="nofollow noreferrer">Non-DI aware scenarios for Data Protection in ASP.NET Core</a> I find the code that is intended to be a console application.</p>
  <p>It is unexpected for me because console application references to ASP.NET Core library:</p>
  <pre><code>using Microsoft.AspNetCore.DataProtection;
  </code></pre>
  <p>When I tried to run it, I expectedly got an error message about missing assembly.</p>
  <p>I asked Microsoft about this <a href="https://github.com/dotnet/AspNetCore.Docs/issues/17098" rel="nofollow noreferrer">https://github.com/dotnet/AspNetCore.Docs/issues/17098</a>. But I just got the come-off answer, I just got the reference to the page which is upper in the content: <a href="https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/introduction?view=aspnetcore-3.1#package-layout" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/introduction?view=aspnetcore-3.1#package-layout</a></p>
  <p>When I run the code in the ASP.NET app, the following statement <code>dataProtectionProvider.CreateProtector(&quot;Program.No-DI&quot;)</code> returned <code>Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector</code>.</p>
  <p>Which library contains <code>KeyRingBasedDataProtector</code>?</p>
  <p>I included the package <a href="https://www.nuget.org/packages/Microsoft.AspNetCore.DataProtection.Abstractions/" rel="nofollow noreferrer">https://www.nuget.org/packages/Microsoft.AspNetCore.DataProtection.Abstractions/</a>, but it expectedly does not contain implementation.</p>
  <p>In general, are ASP.NET libraries are suitable to use in console applications?</p>
  <p>After all, how to run the code from the page <a href="https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/non-di-scenarios?view=aspnetcore-3.1" rel="nofollow noreferrer">Non-DI aware scenarios for Data Protection in ASP.NET Core</a>?</p>
  <p>Thank you</p>