Skip to content

Commit 1697d26

Browse files
Oscar Morantespacepluk
authored andcommitted
do not crash if Assembly has no Location
1 parent f0a94ce commit 1697d26

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Clojure/Clojure/Lib/RT.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3576,16 +3576,25 @@ public static IEnumerable<string> GetFindFilePaths()
35763576
return GetFindFilePathsRaw().Distinct();
35773577
}
35783578

3579+
static string GetAssemblyPath(Assembly assy) {
3580+
if (assy == null || String.IsNullOrEmpty(assy.Location)) {
3581+
return null;
3582+
}
3583+
3584+
return Path.GetDirectoryName(assy.Location);
3585+
}
3586+
35793587
static IEnumerable<string> GetFindFilePathsRaw()
35803588
{
35813589
yield return System.Environment.CurrentDirectory;
35823590
yield return Path.Combine(System.Environment.CurrentDirectory, "bin");
35833591
yield return Directory.GetCurrentDirectory();
3584-
yield return Path.GetDirectoryName(typeof(RT).Assembly.Location);
35853592

3586-
Assembly assy = Assembly.GetEntryAssembly();
3587-
if ( assy != null )
3588-
yield return Path.GetDirectoryName(assy.Location);
3593+
string assyPath;
3594+
assyPath = GetAssemblyPath(typeof(RT).Assembly);
3595+
if (assyPath != null) yield return assyPath;
3596+
assyPath = GetAssemblyPath(Assembly.GetEntryAssembly());
3597+
if (assyPath != null) yield return assyPath;
35893598

35903599
string rawpaths = (string)System.Environment.GetEnvironmentVariable(ClojureLoadPathString);
35913600
if (rawpaths == null)

0 commit comments

Comments
 (0)