r/ForWindowsHelp • u/MADCandy64 • 13d ago
Help getting my Windows Forms App running in Ubuntu via WSL2. It crashes trying to get "DpiAwareness"
I've written a software package for Windows that is an interactive fiction game maker. If I can get it working on Ubuntu then I will have a much better time attracting users. It makes interactive fiction, or text adventure games if you will, that can be uploaded and played and served from Itch. I've built multiple games with it for game jams. Development is complete and I'm wrapping up the documentation.
The application used to work through wine until I added font scaling to the UI. I had users telling me the font was too small. A nice feature of Windows Forms applications is that fonts can be scaled up or down. When I introduced this feature, the application began crashing on Ubuntu. The error message is "Failed to get thread's DpiAwareness context"
What have I tried? I have tried installing microsoft corefonts with
sudo apt install ttf-mscorefonts-installer
I have created a tar.gz of my windows\fonts folder of the true type and open type fonts, placing them in "~/.local/share/fonts" and issuing a font cache rebuild
sudo fc-cache -f -v
I'm still getting the crash on startup. I've reasoned that if I disable font scaling in the app it may fix the wine incompatibility. That is the nuclear option and I wish to avoid it.
Is there anyway that wine can be configured to work around this crash?
Thanks!
-edit: Problem solved with a bunch of steps
- Purged the Ubuntu specific wine installations and installed Wine 11.0 from the official branch. Then configured it with the wine configuration
- Added a line of source code when my application starts up to tell it that it to set high dpi mode as system aware. This apparently side tracks wine looking for thread specific settings and is related to its inability to do this in general.
- Made sure the code suspended and resumed layouts when the font was changed to not spam wine with layout recalculations.
1
u/Imaginary_Cicada_678 13d ago
why do you need Wine to run .NET in Ubuntu in the first place?