Lachee / discord-rpc-csharp

C# custom implementation for Discord Rich Presence. Not deprecated and still available!
MIT License
560 stars 93 forks source link

[BUG] This things fails to work for me #190

Closed blayms closed 1 year ago

blayms commented 2 years ago

Describe the bug I'm just making a BepInEx plugin that can add rich presence while playing the game. Everything might work right, except this: [PASTEBIN TO THE LOG FILE], I think this comes from client.Initialize();. I checked that my app id is right and everything... Cannot find this issue anywhere. I also use Class Library, Framework: Net Standard 2.0

Expected behavior See Rich Presence in Discord

Desktop (please complete the following information):

Additional context help, idk if it even works the way i want to do that

Logs


INFO: Attempting a new connection
INFO: RPC Connection Started
INFO: Attempting to connect to discord-ipc-0
INFO: Connected to discord-ipc-0
ERR : Unhandled Exception: System.PlatformNotSupportedException
ERR : Operation is not supported on this platform.
ERR :   at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod (System.String name, System.Type returnType, System.Type[] parameterTypes, System.Type owner) [0x00018] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor[T] (System.Type type) [0x00010] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator (System.Type createdType) [0x00005] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract contract) [0x0006e] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x00007] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x000f0] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Utilities.ThreadSafeStore`2[TKey,TValue].AddValue (TKey key) [0x00000] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Utilities.ThreadSafeStore`2[TKey,TValue].Get (TKey key) [0x00010] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x0000b] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContract (System.Object value) [0x00011] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe (System.Object value) [0x00005] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00028] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x0023a] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00028] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00007] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at DiscordRPC.IO.PipeFrame.SetObject (System.Object obj) [0x00000] in <3227d928135e426698d3c53e4fc9a77c>:0 
  at DiscordRPC.IO.PipeFrame..ctor (DiscordRPC.IO.Opcode opcode, System.Object data) [0x0000e] in <3227d928135e426698d3c53e4fc9a77c>:0 
  at DiscordRPC.RPC.RpcConnection.EstablishHandshake () [0x0006b] in <3227d928135e426698d3c53e4fc9a77c>:0 
  at DiscordRPC.RPC.RpcConnection.MainLoop () [0x00229] in <3227d928135e426698d3c53e4fc9a77c>:0 
INFO: Attempting a new connection
INFO: RPC Connection Started
INFO: Attempting to connect to discord-ipc-0
ERR : Failed connection to discord-ipc-0. mono-io-layer-error (121)
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to discord-ipc-1
INFO: Connected to discord-ipc-1
ERR : Unhandled Exception: System.PlatformNotSupportedException
ERR : Operation is not supported on this platform.
ERR :   at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod (System.String name, System.Type returnType, System.Type[] parameterTypes, System.Type owner) [0x00018] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor[T] (System.Type type) [0x00010] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator (System.Type createdType) [0x00005] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract contract) [0x0006e] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x00007] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x000f0] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Utilities.ThreadSafeStore`2[TKey,TValue].AddValue (TKey key) [0x00000] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Utilities.ThreadSafeStore`2[TKey,TValue].Get (TKey key) [0x00010] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x0000b] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContract (System.Object value) [0x00011] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe (System.Object value) [0x00005] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00028] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x0023a] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00028] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00007] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in <7d3afc95666543e29e50fb24b8f55032>:0 
  at DiscordRPC.IO.PipeFrame.SetObject (System.Object obj) [0x00000] in <3227d928135e426698d3c53e4fc9a77c>:0 
  at DiscordRPC.IO.PipeFrame..ctor (DiscordRPC.IO.Opcode opcode, System.Object data) [0x0000e] in <3227d928135e426698d3c53e4fc9a77c>:0 
  at DiscordRPC.RPC.RpcConnection.EstablishHandshake () [0x0006b] in <3227d928135e426698d3c53e4fc9a77c>:0 
  at DiscordRPC.RPC.RpcConnection.MainLoop () [0x00229] in <3227d928135e426698d3c53e4fc9a77c>:0 
Lachee commented 2 years ago

Hi, this seems to be a bug with .NET Core 2.0. Please try .NET Core 2.1 and see if that resolves your issue.

https://github.com/dotnet/runtime/issues/23261