Microsoft.Graph Silent crash on new calendar event

Steve Cossette 96 Reputation points
2021-04-08T22:54:10.34+00:00

So, we have a program that synchronizes another platform's appointments to Microsoft Outlook Calendar.

We have several companies that use our service. One of them though is having a problem.

After some troubleshooting, it seems the Microsoft.Graph component makes the program hard crash.

The program is a Win32 Console app running in 64-bit. This is the function being called:

Public Shared Async Function CreateEvent(ByVal token As String, ByVal calendarID As String, ByVal NewEvent As [Event]) As Task(Of Microsoft.Graph.Event)
        Console.WriteLine("Creating Client")
        Dim graphclient As New GraphServiceClient(New DelegateAuthenticationProvider(Function(requestMessage)
                                                                                         requestMessage.Headers.Authorization = New AuthenticationHeaderValue("bearer", token)
                                                                                         Return Task.FromResult(0)
                                                                                     End Function
                            )
                                                                  )

        Dim newcal As [Event]
        Try
            Console.WriteLine("Sending Request")
            newcal = Await graphclient.Me.Calendars.Item(calendarID).Events.Request.AddAsync(NewEvent)
            Console.WriteLine("Request succeded")
        Catch ex As Exception
            GoogleChatMessage("Calendar v2 Debug", "Error occured while creating event, purging calendar." & vbNewLine & vbNewLine & ex.Message & vbNewLine & ex.StackTrace)
        End Try
        Return newcal

    End Function

I added a bunch of console.writelines to see exactly where it crashes. This is what the command prompt looks like:

Creating Client
Sending Request

D:\Tools\GoogleCalendarProcessor>

It doesn't seems to crash in the normal way it seems to just... quit. Or it's a silent crash. There's nothing in the system event log. And this is one of many requests it goes through inside of a do....loop, and it just does the first loop and exits, like if an Environment.exit(0) is being called somewhere (Not in my code)

I already asked the client to make sure that his Office 365 instance is still set to accept API requests, but I don't think this is the problem.

Anyone got an idea of what would cause this? Note I'm still kindof a newbie in coding with Microsoft Graph.

Oh, in case it matters, I use an offline use token provided by the client when they signup on a ASP.net portal.

Thanks!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,592 questions
0 comments No comments
{count} votes

Accepted answer
  1. Steve Cossette 96 Reputation points
    2021-04-09T14:00:50.563+00:00

    Nevermind, I found the problem. It's a really strange one that I don't fully get, but I needed to change:

    newcal = Await graphclient.Me.Calendars.Item(calendarID).Events.Request.AddAsync(NewEvent)
    

    Into

    newcal = graphclient.Me.Calendars.Item(calendarID).Events.Request.AddAsync(NewEvent).Result
    

    Strange how that fixed the problem this single client was experiencing...

    0 comments No comments

0 additional answers

Sort by: Most helpful