Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Crash due to GetExecutingAssembly Location returns empty string #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SaNeOr
Copy link

@SaNeOr SaNeOr commented Sep 20, 2023

In .NET 5 and later versions, for bundled assemblies, the value returned is an empty string and the first parameter of Path.Combine cannot be empty.

https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.location?view=net-5.0#System_Reflection_Assembly_Location

It is enough to use AppContext.BaseDirectory.

In .NET 5 and later versions, for bundled assemblies, the value returned is an empty string.
@lyra95
Copy link

lyra95 commented Nov 24, 2023

Is this fix going to be merged in next release? @skardile-perforce

@skardile-perforce
Copy link
Contributor

skardile-perforce commented Nov 24, 2023

In .NET 5 and later versions, for bundled assemblies, the value returned is an empty string and the first parameter of Path.Combine cannot be empty.

https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.location?view=net-5.0#System_Reflection_Assembly_Location

It is enough to use AppContext.BaseDirectory.

Thanks @SaNeOr for the change.
@lyra95, Yes the team will look into this to accommodate it into next release.

@kalulas
Copy link

kalulas commented Feb 29, 2024

Encountered the same issue with my single-file build application. It would be greatly appreciated if this issue could be fixed in the next release.

@edemartel
Copy link

Since .NET 6, you can also use Environment.ProcessPath to get the path to the executable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants