Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc VB.NET MVC重载解析失败,因为没有可访问的';创建';接受此数量的参数_Asp.net Mvc_Vb.net_Startup_Asp.net Identity_Owin - Fatal编程技术网

Asp.net mvc VB.NET MVC重载解析失败,因为没有可访问的';创建';接受此数量的参数

Asp.net mvc VB.NET MVC重载解析失败,因为没有可访问的';创建';接受此数量的参数,asp.net-mvc,vb.net,startup,asp.net-identity,owin,Asp.net Mvc,Vb.net,Startup,Asp.net Identity,Owin,我正在将VB.NET MVC 5与Identity 2.0一起使用 我一直在尝试配置Startup.Auth,以便在每个请求中自动使用ApplicationDbContext、CustomUserManager和CustomRoleManager的单个实例 我的代码如下:(减去垃圾) 但无论我做什么,都要接受这些错误 重载解析失败,因为没有可访问的“Create”接受此数量的参数 我认为这与我用VB编写的代码和用C#编写的示例有关,尽管这是一个问题,这激怒了我。My CustomUserMana

我正在将VB.NET MVC 5与Identity 2.0一起使用

我一直在尝试配置Startup.Auth,以便在每个请求中自动使用ApplicationDbContext、CustomUserManager和CustomRoleManager的单个实例

我的代码如下:(减去垃圾)

但无论我做什么,都要接受这些错误

重载解析失败,因为没有可访问的“Create”接受此数量的参数

我认为这与我用VB编写的代码和用C#编写的示例有关,尽管这是一个问题,这激怒了我。My CustomUserManager是一个公共类,创建方法是公共共享的

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

有什么想法吗?非常感谢您的帮助,干杯。

如果您已经使用Update 3更新了visual studio 2013。这包括所有的身份信息和自定义用户管理器、角色管理器等

使用MVC模板创建新项目,并使用Visual Studio 2013选择身份验证作为个人用户帐户。然后,您将创建与使用示例实现的代码相同的所有代码。您可以使用这些类和实现来解决自定义用户管理器的问题

检查floder应用程序启动>>IdentityConfig.vb

我在代码中看到的唯一一件事是,您使用了整数作为Id,而不是字符串。这将不会是一个问题,如果你有正确的绑定EF模型投标的东西

试试这个

Public Sub ConfigureAuth(app As IAppBuilder)
    app.CreatePerOwinContext(AddressOf ApplicationDbContext.Create)
End Sub
AddressOf运算符创建一个函数委托,该委托指向procedurename指定的函数

Public Sub ConfigureAuth(app As IAppBuilder)
    app.CreatePerOwinContext(AddressOf ApplicationDbContext.Create)
End Sub