0

The plan to make an C# dll file then add that dll file into MS access VBA code by making COM Everything is working fine in C# code Except the fact that when I use debugger in C# it shows "GoogleWebAuthorizationBrokes.cs not found" and I have to use continue button to execute further code, else the code runs fine and create an event in the google calendar But when I use call the Method from VBA it goes to the C# but do not execute the entire methode

public string CalendarMethod(string Email, string text)
        {
            try
            {

    Msg = "Credential started";
                    UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                        new ClientSecrets
                        {
                            ClientId = "ClientID",
                            ClientSecret = "ClientSecret",
                        },
                        new[] { CalendarService.Scope.Calendar },
                        "user",
                        CancellationToken.None).Result;
                    Msg = "Credential Executed";
                    // Create the service.
                    var service = new CalendarService(new BaseClientService.Initializer()
                    {
                        HttpClientInitializer = credential,
                        ApplicationName = "Calendar API Sample",
                    });
                    Msg = "Service Executed";
                    Event myEvent = new Event()
                    {
                        Summary = "Test Event",
                        Location = "City",
                        Start = new EventDateTime()
                        {
                            DateTime = DateTime.Now,
                            TimeZone = "America/Los_Angeles"
                        },
                        End = new EventDateTime()
                        {
                            DateTime = DateTime.Now,
                            TimeZone = "America/Los_Angeles"
                        },
                        Recurrence = new String[] {
                      "RRULE:FREQ=WEEKLY;BYDAY=MO"
                  },
                        Attendees = new List<EventAttendee>()
                        {
                            new EventAttendee() { Email = "ishooagarwal@gmail.com" } 
                        }
                    };

                    Event recurringEvent = service.Events.Insert(myEvent, "primary").Execute();
                    Msg = "Event Executed";
                    return "Executed" + Msg;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex + Msg);
                    return "Not executed" + Msg +ex;
                }
            }

It always return from Credential Started It returns a huge msg at VBA side System.AggregateException One or more errors occured -------> System.IO.FileNotFoundException could not load filem or assembly "System.Net.Http.Primitives, Version=1.5.0.0, culture=neutral, publicKeyToken=b03......." or one of its dependencies, The system cannot find the file specified at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess{Task task} at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess{Task task} at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.

1 Answers1

0

Looks like when you are calling GoogleWebAuthorizationBroker.AuthorizeAsync method, it is looking for a dependency of System.Net.Http.Primitives which is not on the executing machine.

Make sure this reference is deployed with your application.

This looks like a duplicate issue.

Could not load file or assembly System.Net.Http.Primitives. Located assembly's manifest definition does not match the assembly reference

Community
  • 1
  • 1
Scott Wylie
  • 4,725
  • 2
  • 36
  • 48