DSharpPlus: `System.MemberAccessException` on initial startup with .NET Core 3.0 Preview builds

Summary

After the DiscordClient.ConnectAsync() is called it appears that some part in WebSocket throws an exception. System.MemberAccessException: Type initializer was not callable. is thrown and every single message received leaves a warning [Event] [Warning] Could not find channel last message belonged to.. Essentially all things just break apart, like not being able to GetChannel() and whatnot…

Details

Environment

  • Raspberry Pi 3B+ with Raspbian. It was a relatively fresh install (just finished updating and installed docker). Happened when I tried:
    • Docker .NET Core 3.0 preview image (mcr.microsoft.com/dotnet/core/runtime:3.0), with framework dependent deployment builds
    • Ran directly in Raspbian, self-deployed build
  • Cannot be reproduced on Windows 10 w/ .NET Core 3.0 P5

Console output

root@90baf8ca8bbf:/app# dotnet ./AyyLmao.dll
[2019-06-05 22:03:19 +00:00] [DSharpPlus] [Info] DSharpPlus, version 4.0.0-nightly-00600
[2019-06-05 22:03:20 +00:00] [REST] [Debug] Initial Request for bucket Rate limit bucket [GET::::/gateway/bot] [0/0] 01/01/0001 00:00:00 +00:00. Allowing.
[2019-06-05 22:03:21 +00:00] [REST] [Debug] Initial Request for bucket Rate limit bucket [GET::::/users/:user_id] [0/0] 01/01/0001 00:00:00 +00:00. Allowing.
[2019-06-05 22:03:22 +00:00] [REST] [Debug] Initial Request for bucket Rate limit bucket [GET::::/oauth2/applications/:application_id] [0/0] 01/01/0001 00:00:00 +00:00. Allowing.
[2019-06-05 22:03:22 +00:00] [REST] [Debug] Initial Request for bucket Rate limit bucket [GET::::/voice/regions] [0/0] 01/01/0001 00:00:00 +00:00. Allowing.
[2019-06-05 22:03:23 +00:00] [Websocket] [Debug] Received OP 10 (HELLO) - Trying to either resume or identify.
[2019-06-05 22:03:23 +00:00] [Websocket] [Debug] Starting Heartbeat.
[2019-06-05 22:03:23 +00:00] [Websocket] [Debug] Sending Heartbeat.
[2019-06-05 22:03:23 +00:00] [Websocket] [Debug] Received WebSocket Heartbeat Ack. Ping: 203ms
[2019-06-05 22:03:24 +00:00] [Websocket] [Error] Socket swallowed an exception:
System.MemberAccessException: Type initializer was not callable.
   at System.Reflection.RuntimeConstructorInfo.ThrowNoInvokeException()
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at DSharpPlus.Net.Serialization.SnowflakeArrayAsDictionaryJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject[T]()
   at DSharpPlus.DiscordClient.HandleDispatchAsync(GatewayPayload payload)
   at DSharpPlus.DiscordClient.HandleSocketMessageAsync(String data)
   at DSharpPlus.DiscordClient.<InternalConnectAsync>g__SocketOnMessage|60_1(SocketMessageEventArgs e)

// A message was sent in Discord guild that the bot belongs to
[2019-06-05 22:03:39 +00:00] [Event] [Warning] Could not find channel last message belonged to.

Steps to reproduce

  1. write some nice bots using DSharpPlus :^)
  2. Enable internal logging feature
  3. Run it on Linux ARM64 build of .NET Core Preview 5? Not sure if this happens on Linux x64 as well. It didn’t happen on Windows x64 builds.
  4. Observe the exceptions being logged.

Notes

Will update once I try it with .NET Core 2.2.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I know what BindingFlags is, Einstein. I however did not (at the time of writing that code) know static constructors were treated the same as instance ones at runtime.