Skip to content

Commit

Permalink
Throwing Exceptions when trying to load an Already Loaded Assembly. S…
Browse files Browse the repository at this point in the history
…hould mitigate the TweakScale/Companion_Frameworks#6 problem, as well any other idiot that do the same stupidity as I did. #facePalm
  • Loading branch information
Lisias committed May 7, 2023
1 parent 4fb3c52 commit 43eea13
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Source/KSPe/Util/SystemTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ public class Exception : Assembly.Exception
protected Exception(string message, string assemblyName) : base(message, assemblyName) { }
}

public class AlreadyLoadedException : Exception
{
private static readonly string MESSAGE = "The Assembly {0} is already loaded!";
internal AlreadyLoadedException(string assemblyName) : base(MESSAGE, assemblyName) { }
}

protected static readonly object MUTEX = new object();
protected readonly string effectivePath;
protected readonly string searchPath;
Expand Down Expand Up @@ -321,6 +327,8 @@ void IDisposable.Dispose()

public SReflection.Assembly LoadAndStartup(string assemblyName)
{
if (Assembly.Exists.ByName(assemblyName))
throw new AlreadyLoadedException(assemblyName);
return Assembly.LoadAndStartup(assemblyName);
}
}
Expand Down

0 comments on commit 43eea13

Please sign in to comment.