discord / gamesdk-and-dispatch

Public issue tracker for the Discord Game SDK and Dispatch
22 stars 7 forks source link

Initializing the Discord GameSDK in UWP resulting in a crash #118

Closed RythenGlyth closed 3 years ago

RythenGlyth commented 3 years ago

Describe the bug When trying to connect to Discord, as explained in the docs by using discord = new Discord.Discord(CLIENT_ID, (UInt64)Discord.CreateFlags.Default);, the DiscordCreate method fails, resulting in a crash, with the message

This file does not have an app associated with it for performing this action. Please install an app or, if one is already installed, create an assicciation in the Default Apps Settings Page

Steps to reproduce

  1. Create a UWP C# App in Visual Studio
  2. Add The CSharp GameSDK Files into the DiscordGameSDK folder
  3. Add the discord_game_sdk.dll by drag and drop into the project
  4. Make the dll Copy to Output Directory
  5. Add discord = new Discord.Discord(CLIENT_ID, (UInt64)Discord.CreateFlags.Default); to the Constructor of the MainPage.xaml.cs
  6. Start the Program

Expected behavior

Screenshots https://i.imgur.com/c0ONVPr.jpg

Implementation specifics

Additional context When i use Windows.System.Launcher.LaunchUriAsync(new Uri("discord:///CLIENT_ID/launch"));, discord opens, as it's supposed to

vkuhlmann commented 3 years ago

I'm afraid there are some technical issues to supporting UWP. These are fragments of conservations in the Discord Developers server (https://discord.gg/discord-developers):

https://canary.discord.com/channels/613425648685547541/613425918748131338/639173198591819821

UWP apps on Windows, for example, don't let you do local sockets IIRC? So the IPC protocol just doesn't work

https://canary.discord.com/channels/613425648685547541/613425918748131338/730157267961381014

the sdk will never work in UWP because the SDK DLL targets the desktop platform, it can't be loaded in a UWP app you'd need a runFullTrust component doing the rich presence

Jump-Suit commented 3 years ago

I believe it also has to do with UMP apps being Sandboxed from Windows. So IPC wouldn't work. image Refer to here: https://discordapp.com/channels/613425648685547541/613425918748131338/639203539054231593

vkuhlmann commented 3 years ago

The restriction to sockets on UWP is documented on https://docs.microsoft.com/en-us/windows/uwp/networking/sockets (see the Note)

Jump-Suit commented 3 years ago

Then that resolves this issue since you are now aware of the restriction. EDIT: didn't realize, vkuhlmann, your not the original author of this issue.

RythenGlyth commented 3 years ago

Ok so as I understand it, it can't work with the concept of UWP. For others who have the same issue, i am now using Windows UI Library 3 - Project Reunion 0.5, which uses the new mordern Windows UI style but inside a normal Windows Desktop Application with all the rights you need

sylveon commented 3 years ago

The SDK doesn't use sockets on Windows, it uses named pipes. However, low IL processes (UWP processes) cannot connect to named pipes from medium IL processes (Win32 apps) without the ACL allowing this to happen (by default it doesn't).