title: VB.NET MVC Overload resolution failed because no accessible 'Create' accepts this number of arguments
body: <p>I'm using <strong>VB.NET MVC 5</strong> with <strong>Identity 2.0</strong>.</p>
  
  <p>I've been trying to configure my Startup.Auth to automatically use a single instance of ApplicationDbContext, CustomUserManager and CustomRoleManager per request <a href="http://www.codeproject.com/Articles/762428/ASP-NET-MVC-and-Identity-Understanding-the-Basics#premain2" rel="nofollow">as detailed in this tutorial</a>.</p>
  
  <p>My code is as follows: (minus garbage)</p>
  
  <pre><code>Public Sub ConfigureAuth(app As IAppBuilder)
      app.CreatePerOwinContext(ApplicationDbContext.Create)
      ' Error 135 Overload resolution failed because no accessible 'CreatePerOwinContext' can be called with these arguments:
      '   Extension method 'Public Function CreatePerOwinContext(Of T)(createCallback As System.Func(Of Microsoft.AspNet.Identity.Owin.IdentityFactoryOptions(Of T), Microsoft.Owin.IOwinContext, T)) As Owin.IAppBuilder' defined in 'Owin.AppBuilderExtensions': Data type(s) of the type parameter(s) cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
      '   Extension method 'Public Function CreatePerOwinContext(Of T)(createCallback As System.Func(Of T)) As Owin.IAppBuilder' defined in 'Owin.AppBuilderExtensions': Data type(s) of the type parameter(s) cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
  
      app.CreatePerOwinContext(Of CustomUserManager)(CustomUserManager.Create)
      ' Error 136 Overload resolution failed because no accessible 'Create' accepts this number of arguments.
      ....
  End Sub
  </code></pre>
  
  <p>But recieve these errors no matter what I do</p>
  
  <blockquote>
    <p>Overload resolution failed because no accessible 'Create' accepts this number of arguments.</p>
  </blockquote>
  
  <p>I think it's to do with me writing in VB and the example being in C#, though it infuriates me that this is a problem. My CustomUserManager is a Public Class, and the Create method is Public Shared.</p>
  
  <pre><code>Public Shared Function Create(options As IdentityFactoryOptions(Of CustomUserManager), context As IOwinContext) As CustomUserManager
      Dim manager As CustomUserManager
      manager = New CustomUserManager(New CustomUserStore(context.Get(Of ApplicationDbContext)()))
      manager.UserValidator = New UserValidator(Of ApplicationUser, Integer)(manager)
      manager.PasswordValidator = New PasswordValidator() With {
          .RequiredLength = 6
      }
      manager.RegisterTwoFactorProvider("EmailCode",
          New EmailTokenProvider(Of ApplicationUser, Integer)() With {
              .Subject = "Security Code",
              .BodyFormat = "Your security code is: {0}"
          }
      )
      manager.EmailService = New EmailService()
      manager.SmsService = New SmsService()
      If Not options.DataProtectionProvider Is Nothing Then
          manager.UserTokenProvider = New DataProtectorTokenProvider(Of ApplicationUser, Integer)(options.DataProtectionProvider.Create("ASP.NET Identity"))
      End If
      Return manager
  End Function
  </code></pre>
  
  <p>Any ideas anyone? Any help is much appreciated, Cheers.</p>