We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c42acda commit 0ba2443Copy full SHA for 0ba2443
src/NLog/Internal/Fakeables/AppEnvironmentWrapper.cs
@@ -99,7 +99,19 @@ private static string LookupEntryAssemblyFileName()
99
{
100
try
101
102
- return Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly()?.Location ?? string.Empty);
+ var entryAssembly = System.Reflection.Assembly.GetEntryAssembly();
103
+ var assemblyLocation = entryAssembly?.Location;
104
+ if (!string.IsNullOrEmpty(assemblyLocation))
105
+ {
106
+ return Path.GetFileName(assemblyLocation);
107
+ }
108
+
109
+ // Fallback to the Assembly-Name when unable to extract FileName from Location
110
+ var assemblyName = entryAssembly?.GetName()?.Name;
111
+ if (!string.IsNullOrEmpty(assemblyName))
112
+ return assemblyName + ".dll";
113
+ else
114
+ return string.Empty;
115
}
116
catch (Exception ex)
117
0 commit comments