System.IO.FileLoadException while using Google Calendar 3


I am using the following code to connect to Google Calendar 3.

Dim datafolder As String = Server.MapPath("App_Data/")
Dim scopes As IList(Of String) = New List(Of String)()
Dim UserId As String = "".Trim()
Dim myclientsecret As New ClientSecrets() With { _
  .ClientId = myClientID, _ ' It is saved in the web config
  .ClientSecret = ClientSecret _  ' It is saved in the web config

Dim flow As GoogleAuthorizationCodeFlow
    flow = New GoogleAuthorizationCodeFlow(New GoogleAuthorizationCodeFlow.Initializer() With { _
      .DataStore = New FileDataStore(datafolder), _
      .ClientSecrets = myclientsecret, _
      .Scopes = scopes
Catch ex As Exception
    lblerr.Text = ex.ToString
End Try

It throws:

System.TypeInitializationException: The type initializer for 'Google.Apis.Http.ConfigurableMessageHandler' threw an exception.

System.IO.FileLoadException: Could not load file or assembly 'System, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

What am I doing wrong with this coding? Why am I not getting authenticated?
asked on Stack Overflow Dec 20, 2014 by (unknown user) • edited Jun 20, 2020 by Community

1 Answer


I have seen a similar error when using external libraries (e.g. DLL's) which are downloaded from the internet. Your post doesn't mention this, but I'll post here just in case this applies to you.

Make sure any external libraries used by your project are not blocked by Windows. You can do this by right-clicking the library file (e.g. the DLL) and going to Properties. At the bottom, if this applies, there will be a button to "Unblock". Click it and then try to run your project again.

Additional info and automation options can be found here:

answered on Stack Overflow Dec 20, 2014 by Jason Faulkner • edited Dec 20, 2014 by Jason Faulkner

User contributions licensed under CC BY-SA 3.0