We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3909 - [WinRT] [Patch] Fix support for C# UWP applications
Summary: [WinRT] [Patch] Fix support for C# UWP applications
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: main (show other bugs)
Version: 2.0.6
Hardware: All Windows 10
: P2 normal
Assignee: David Ludwig
QA Contact: David Ludwig
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-22 17:45 UTC by Ethan Lee
Modified: 2017-11-02 00:35 UTC (History)
2 users (show)

See Also:


Attachments
Move Windows::Foundation::Initialize to SDL2.dll, from SDL_main (1.64 KB, text/plain)
2017-10-22 17:45 UTC, Ethan Lee
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ethan Lee 2017-10-22 17:45:36 UTC
Created attachment 3026 [details]
Move Windows::Foundation::Initialize to SDL2.dll, from SDL_main

Attached is a patch that moves Windows::Foundation::Initialize out of the WinMain function into the DLL. Functionally this should be no different for existing applications, but for C# applications this allows us to use SDL2's UWP support by simply calling SDL_WinRTRunApp. Unfortunately we can't call Initialize ourselves from a C# environment, so this seemed like the best solution.

I asked David Ludwig and at first glance he seemed to think it was okay, but WinRT can be a cruel beast... this works for us but I don't know if this somehow violates some obscure UWP rule by not having this call in the EXE. All the docs imply that it should be in WinMain but I don't see anything that explicitly says it's required.
Comment 1 David Ludwig 2017-10-30 23:44:09 UTC
This change looks fine to me, and runs ok on my system.

I also tried testing it against the older, WinRT, WinMain-providing file (Ethan's patch alters it a bit, along with some code in SDL's dll), and it still works ok.
Comment 2 David Ludwig 2017-10-30 23:46:11 UTC
Committed to hg, via https://hg.libsdl.org/SDL/rev/bd1495ebc979

Thanks, Ethan!
Comment 3 Sam Lantinga 2017-11-02 00:35:45 UTC
Thanks!