benruehl / adonis-ui

Lightweight UI toolkit for WPF applications offering classic but enhanced windows visuals
https://benruehl.github.io/adonis-ui/
MIT License
1.69k stars 143 forks source link

.NET 5 fix singlefile apps crashing on fetching app icon #164

Closed Insire closed 2 years ago

Insire commented 3 years ago

Fixes #159

When a application using AdonisUI uses .net5 was compiled as

<SelfContained>true</SelfContained> and <PublishSingleFile>true</PublishSingleFile>

then Assembly.GetEntryAssembly()?.ManifestModule.FullyQualifiedName won't return a valid filename.

I replaced that call with

Process.GetCurrentProcess().MainModule.FileName

and also added a check for the returned path actually pointing to a valid file, just in case things change again in the future.

Insire commented 2 years ago

Is there anything i can do, to get this merged?

benruehl commented 2 years ago

Thanks for contributing! Sorry it took me so long to look at your changes. It seems that this doesn't quite work though. The demo app has no icon anymore. Which makes sense because if the file path is found null is returned.

Insire commented 2 years ago

Hi, thanks for taking a look at this.

There was indeed a bug here. I've updated the PR accordingly. Could you take a look again?

Also can you clarify what Demo-App and Icon you were referring to? Even with my most recent changes, i fail to find the difference, that should be visibile, in the AdoniUI.Demo?

benruehl commented 2 years ago

Thanks for updating, I'll take a look.

And yes, I am referring to the AdonisUI.Demo app. By default, you don't see it because the title bar is in the PlaceTitleBarOverContent mode. In order to see it, you need to start the app and enable the "Title bar" setting in the top left corner. This brings up the default title bar which then has no icon like it had before the changes.

Insire commented 2 years ago

I see, that makes sense. Seems to be working then, from what i can tell:

grafik