Created
May 11, 2023 00:38
-
-
Save chuongmep/8fa30b1f9ade9a5cf952c621e27376db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string assPath = Assembly.GetExecutingAssembly().Location; | |
string? dirPath = Path.GetDirectoryName(Path.GetFullPath(assPath)) ?? null; | |
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => | |
{ | |
var assemblyName = new AssemblyName(args.Name); | |
if (!string.IsNullOrEmpty(dirPath)) | |
{ | |
var assemblyPath = Path.Combine(dirPath, assemblyName.Name + ".dll"); | |
if (File.Exists(assemblyPath) == false) return null; | |
var assembly = Assembly.LoadFrom(assemblyPath); | |
return assembly; | |
} | |
return null; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment