System.TypeLoadException с использованием Google.Apis.Auth. Mvc FlowMetadata - PullRequest
0 голосов
/ 03 августа 2020

Я пытаюсь реализовать Google.Apis.Auth. Mvc FlowMetadata в моем asp. net Mvc проекте, на самом деле я использую ту же реализацию документации Google: Реализовать на ASP. NET MVC, я использую тот же код в своей собственной реализации, но получаю эту ошибку:

Hora del evento: 2/08/2020 11:14:25 p.m.
Id. de problema: System.TypeLoadException at MyDemoProject.Controllers.AutenticacionController.Index
Mensaje: El método 'GetUserId' en el tipo 'MyDemoProject.Services.AppMyDemoProjectFlMetadata' del 
ensamblado 'MyDemoProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' no tiene una 
implementación.
Tipo de excepción: System.TypeLoadException
Versión del SDK: 1.2.3.490

Seguimiento de la pila
System.TypeLoadException: El método 'GetUserId' en el tipo 
'MyDemoProject.Services.AppMyDemoProjectFlMetadata' del ensamblado 'MyDemoProject, Version=1.0.0.0, 
Culture=neutral, PublicKeyToken=null' no tiene una implementación.
en  MyDemoProject.Controllers.AutenticacionController.Index
en  lambda_method
en  System.Web.Mvc.ActionMethodDispatcher.Execute
en  System.Web.Mvc.ReflectedActionDescriptor.Execute
en  System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod
en  System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`2.CallEndDelegate
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.End
en  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod
en  System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters. 
<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d
en  System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass46. 
<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f
en  System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass33. 
<BeginInvokeActionMethodWithFilters>b__32
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1.CallEndDelegate
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.End
en  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters
en  System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass21+<>c__DisplayClass2b. 
<BeginInvokeAction>b__1c
en  System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass21.<BeginInvokeAction>b__1e
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1.CallEndDelegate
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.End
en  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction
en  System.Web.Mvc.Controller.<BeginExecuteCore>b__1d
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1.CallEndDelegate
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.End
en  System.Web.Mvc.Controller.EndExecuteCore
en  System.Web.Mvc.Controller.<BeginExecute>b__15
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1.CallEndDelegate
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.End
en  System.Web.Mvc.Controller.EndExecute
en  System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute
en  System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1.CallEndDelegate
en  System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.End
en  System.Web.Mvc.MvcHandler.EndProcessRequest
en  System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest
en  
System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
en  System.Web.HttpApplication.ExecuteStepImpl
en  System.Web.HttpApplication.ExecuteStep

Это моя реализация:

public class AppFlowMetadata : FlowMetadata
{
    private static readonly IAuthorizationCodeFlow flow =
        new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
        {
            ClientSecrets = new ClientSecrets
            {
                ClientId = "TheClientIDProvidedByGoogle",
                ClientSecret = "TheClientSecretProvidedByGoogle"
            },
            Scopes = new[] { DriveService.Scope.Drive },
            DataStore = new FileDataStore("Drive.Api.Auth.Store")
        });

    public override string GetUserId(Controller controller)
    {
        // In this sample we use the session to store the user identifiers.
        // That's not the best practice, because you should have a logic to identify
        // a user. You might want to use "OpenID Connect".
        // You can read more about the protocol in the following link:
        // https://developers.google.com/accounts/docs/OAuth2Login.
        var user = controller.Session["user"];
        if (user == null)
        {
            user = "mn-02-11-4";
            controller.Session["user"] = user;
        }
        return user.ToString();

    }

    public override IAuthorizationCodeFlow Flow => flow;

}

Благодарю за всю помощь.

Спасибо

...