`System.MemberAccessException` on initial startup with .NET Core 3.0 Preview builds
See original GitHub issueSummary
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
- Docker .NET Core 3.0 preview image (
- 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
- write some nice bots using DSharpPlus :^)
- Enable internal logging feature
- 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.
- Observe the exceptions being logged.
Notes
Will update once I try it with .NET Core 2.2.
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (14 by maintainers)
Top Results From Across the Web
Error on startup after upgrading from .Net Core 3.0 preview ...
1 Answer. Delete all previously published files (dlls are important to be deleted), upgrade all dependencies to previews for . net core 3.0...
Read more >NET Core 3.0 Preview 1 makes app fail to start · Issue #5700
dotnet (start). Expected: app starts. Actual: exception is displayed. Application startup exception: System.InvalidOperationException: Scheme ...
Read more >Breaking changes in .NET Core 3.0
Starting in ASP.NET Core 3.0 Preview 5, the fields in Microsoft.Net.Http.Headers.HeaderNames changed from const to static readonly .
Read more >Announcing .NET Core 3.0 Preview 6
Today, we are announcing .NET Core 3.0 Preview 6. It includes updates for compiling assemblies for improved startup, optimizing applications ...
Read more >ASP.NET Core 3.0 not showing on Visual Studio 2019
1- make sure Tools -> Options that enables preview versions of the .NET Core SDK enabled. 2- uninstall all x86 version of .net...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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.
while testing issue #477 I also came across a
System.MemberAccessException
on linux ARM64, by calling DiscordClient.GetGuildAsync, more info about my setup is in that issue.full stack trace: