vb.net 中的 BC36645 错误

BC36645 error in vb.net

我正在使用 Visual Studio 2015 开发一个使用 Web 表单和 Visual Basic 的网站。我的问题是发生错误 BC36645,阻止我构建解决方案。它被描述为 "Data type(s) of the type parameter(s) in method 'Public Shared Overloads Function FromResult(Of TResult)(result As TResult) As Task(Of TResult)' cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error."

其中的基本意思我明白了。但是,据说它在我没有触及的文件中,它是自动生成的。该文件 IdentityModels.vb 位于模型文件夹中。

我在同一个解决方案的另一个项目中得到了同样的错误,我通过删除、重新创建项目和重建解决了这个问题。但这并不是真正解决问题的便捷方法。

有没有人遇到同样的问题,可以解释一下是什么问题,甚至有一个合适的解决方案?

//伊娃-洛塔

编辑:

这是错误指向的文件的内容(错误在“Return Task.FromResult(GenerateUserIdentity(manager))”:

Imports System
Imports System.Threading.Tasks
Imports System.Security.Claims
Imports Microsoft.AspNet.Identity
Imports Microsoft.AspNet.Identity.EntityFramework
Imports Microsoft.AspNet.Identity.Owin
Imports Microsoft.Owin.Security

Public Class ApplicationUser
    Inherits IdentityUser

Public Function GenerateUserIdentity(manager As ApplicationUserManager) As 

    Dim userIdentity = manager.CreateIdentity(Me, DefaultAuthenticationTypes.ApplicationCookie)

    Return userIdentity
End Function

Public Function GenerateUserIdentityAsync(manager As ApplicationUserManager) 
    As Task(Of ClaimsIdentity)
        Return Task.FromResult(GenerateUserIdentity(manager))
End Function

End Class

Public Class ApplicationDbContext
Inherits IdentityDbContext(Of ApplicationUser)
Public Sub New()
    MyBase.New("DefaultConnection", throwIfV1Schema:=False)
End Sub

Public Shared Function Create As ApplicationDbContext
    Return New ApplicationDbContext()
End Function    

结束Class

#Region "Helpers"
Public Class 
Public Const XsrfKey As String = "xsrfKey"

Public Const ProviderNameKey As String = "providerName"
Public Shared Function GetProviderNameFromRequest(request As HttpRequest) As String
    Return request.QueryString(ProviderNameKey)
End Function

Public Const CodeKey As String = "code"
Public Shared Function GetCodeFromRequest(request As HttpRequest) As String
    Return request.QueryString(CodeKey)
End Function

Public Const UserIdKey As String = "userId"
Public Shared Function GetUserIdFromRequest(request As HttpRequest) As String
    Return HttpUtility.UrlDecode(request.QueryString(UserIdKey))
End Function

Public Shared Function GetResetPasswordRedirectUrl(code As String, request As HttpRequest) As String
    Dim absoluteUri = "/Account/ResetPassword?" + CodeKey + "=" + HttpUtility.UrlEncode(code)
    Return New Uri(request.Url, absoluteUri).AbsoluteUri.ToString()
End Function

Public Shared Function GetUserConfirmationRedirectUrl(code As String, userId As String, request As HttpRequest) As String
    Dim absoluteUri = "/Account/Confirm?" + CodeKey + "=" + HttpUtility.UrlEncode(code) + "&" + UserIdKey + "=" + HttpUtility.UrlEncode(userId)
    Return New Uri(request.Url, absoluteUri).AbsoluteUri.ToString()
End Function

Private Shared Function IsLocalUrl(url As String) As Boolean
    Return Not String.IsNullOrEmpty(url) AndAlso ((url(0) = "/"c AndAlso (url.Length = 1 OrElse (url(1) <> "/"c AndAlso url(1) <> "\"c))) OrElse (url.Length > 1 AndAlso url(0) = "~"c AndAlso url(1) = "/"c))
End Function

Public Shared Sub RedirectToReturnUrl(returnUrl As String, response As HttpResponse)
    If Not [String].IsNullOrEmpty(returnUrl) AndAlso IsLocalUrl(returnUrl) Then
        response.Redirect(returnUrl)
    Else
        response.Redirect("~/")
    End If
End Sub
End Class
#End Region

解决此错误您可以为一个或多个类型参数指定数据类型,而不是依赖类型推断。