Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ LoadAssemblyByPath()

static Assembly System.Xml.Serialization.TempAssembly.LoadAssemblyByPath ( Type type,
string assemblyName )
inlinestaticprivate

Definition at line 201 of file TempAssembly.cs.

202 {
203 Assembly result = null;
204 string text = null;
205 try
206 {
207 if (!string.IsNullOrEmpty(type.Assembly.Location))
208 {
209 text = Path.Combine(Path.GetDirectoryName(type.Assembly.Location), assemblyName + ".dll");
210 }
211 if ((string.IsNullOrEmpty(text) || !File.Exists(text)) && !string.IsNullOrEmpty(Assembly.GetEntryAssembly()?.Location))
212 {
214 }
215 if ((string.IsNullOrEmpty(text) || !File.Exists(text)) && !string.IsNullOrEmpty(AppContext.BaseDirectory))
216 {
217 text = Path.Combine(Path.GetDirectoryName(AppContext.BaseDirectory), assemblyName + ".dll");
218 }
219 if (!string.IsNullOrEmpty(text))
220 {
221 result = Assembly.LoadFile(text);
222 }
223 }
224 catch (Exception ex)
225 {
226 if (ex is ThreadAbortException || ex is StackOverflowException || ex is OutOfMemoryException)
227 {
228 throw;
229 }
230 }
231 return result;
232 }
static bool Exists([NotNullWhen(true)] string? path)
Definition File.cs:97
static string Combine(string path1, string path2)
Definition Path.cs:304
static ? string GetDirectoryName(string? path)
Definition Path.cs:121
static ? Assembly GetEntryAssembly()
Definition Assembly.cs:486
static Assembly LoadFile(string path)
Definition Assembly.cs:518

References System.AppContext.BaseDirectory, System.IO.Path.Combine(), System.IO.File.Exists(), System.IO.Path.GetDirectoryName(), System.Reflection.Assembly.GetEntryAssembly(), System.Reflection.Assembly.LoadFile(), System.text, and System.type.

Referenced by System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly().