title: Unable to configure 'IApplicationBuilder UseOwin'
body: <p>As stated in official <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/owin" rel="nofollow noreferrer">document</a>, I am trying to implement <code>UseOwin</code> in the <code>Startup.cs.</code>I am trying to use/port <code>IAppBuilder (Microsoft.Owin.Builder.AppBuilder)</code> inside <code>IApplicationBuilder (Microsoft.AspNetCore.Builder.IApplicationBuilder)</code>. I had legacy code written using <code>IAppBuilder</code> running fine on .Net Framework 4.5. </p>
  
  <p>I have seen couple of examples about using IAppBuilder in IAplicationBuilder e.g. <a href="https://www.codeproject.com/Articles/1122162/Implement-Owin-Pipeline-using-Asp-net-Core" rel="nofollow noreferrer">example 1</a> <a href="https://github.com/tusdotnet/tusdotnet/wiki/Troubleshoot:-%22&#39;IApplicationBuilder&#39;-does-not-contain-a-definition-for-&#39;UseTus&#39;%22-in-ASP.NET-Core" rel="nofollow noreferrer">example 2</a>. These attempts were about .netcore 1.1 and not .net core 2.0. May be this is the reason i am unable to port. </p>
  
  <p>Please share your thoughts whether i am trying to achieve something not possible at the moment in .net core 2.0 or there is some error in my code. </p>
  
  <p>Note:
  I am using <code>dotnetcore 2.0</code> with <code>Visual Studio 2017</code></p>
  
  <p><strong>Error</strong></p>
  
  <p>I am getting following error.</p>
  
  <blockquote>
    <p>return owinAppBuilder.Build,
    Task>>(); TypeLoadException: Could not load type
    'System.Security.Cryptography.DpapiDataProtector' from assembly
    'System.Security, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a'.</p>
  </blockquote>
  
  <p><strong>My attempt</strong></p>
  
  <pre><code>    app.UseOwin(setup =&gt; setup(next =&gt;
      {
          var owinAppBuilder = new AppBuilder();
  
          var aspNetCoreLifetime =
              (IApplicationLifetime)app.ApplicationServices.GetService(typeof(IApplicationLifetime));
  
          new AppProperties(owinAppBuilder.Properties)
          {
              OnAppDisposing = aspNetCoreLifetime?.ApplicationStopping ?? CancellationToken.None,
              DefaultApp = next,
              AppName = "test"
          };
  
          // Only required if CORS is used, configure it as you wish
          var corsPolicy = new System.Web.Cors.CorsPolicy
          {
  
              AllowAnyHeader = true,
              AllowAnyMethod = true,
              AllowAnyOrigin = true,
              SupportsCredentials = true
          };
  
          //corsPolicy.GetType()
          //      .GetProperty(nameof(corsPolicy.ExposedHeaders))
          //      .SetValue(corsPolicy, tusdotnet.Helpers.CorsHelper.GetExposedHeaders());
  
          owinAppBuilder.UseCors(new Microsoft.Owin.Cors.CorsOptions
          {
              PolicyProvider = new CorsPolicyProvider
              {
                  PolicyResolver = context =&gt; Task.FromResult(corsPolicy)
              }
          });
  
          PublicClientId = "self";
  
          OAuthAuthorizationServerOptions OAuthOptions = new OAuthAuthorizationServerOptions
          {
              TokenEndpointPath = new Microsoft.Owin.PathString("/Login"),
              Provider = new MyServiceProvider(PublicClientId),
  
              AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(60),
              AllowInsecureHttp = true,
              RefreshTokenProvider = new MyRefreshTokenProvider(),
          };
  
          owinAppBuilder.UseOAuthBearerTokens(OAuthOptions);
          //owinAppBuilder.UseTus(context =&gt; new DefaultTusConfiguration
          //{
          //    // Excluded for brevity, use the same configuration as you would normally do
          //});
  
  
          return owinAppBuilder.Build&lt;Func&lt;IDictionary&lt;string, object&gt;, Task&gt;&gt;();
      }));
  </code></pre>