Skip to content

Commit 9ba9452

Browse files
committed
🐛 Assembly.GetEntryAssembly() can return null - instead of failing with a null-deref, rather fail explicitly with an hint on how to work around the problem
1 parent fa1b0af commit 9ba9452

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/log4net/Util/SystemInfo.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ public static string EntryAssemblyLocation
202202
#elif NETSTANDARD1_3 // TODO GetEntryAssembly is available for netstandard1.5
203203
return entryAssemblyLocation = AppContext.BaseDirectory;
204204
#else
205-
return entryAssemblyLocation = System.Reflection.Assembly.GetEntryAssembly().Location;
205+
return entryAssemblyLocation = Assembly.GetEntryAssembly()?.Location
206+
?? throw new InvalidOperationException($"Unable to determine EntryAssembly location: EntryAssembly is null. Try explicitly setting {nameof(SystemInfo)}.{nameof(EntryAssemblyLocation)}");
206207
#endif
207208
}
208209
set => entryAssemblyLocation = value;

0 commit comments

Comments
 (0)