Files
speckle-sharp-connectors/Sdk/Speckle.Autofac/AssemblyResolver.cs
T
2024-07-04 11:56:34 +01:00

27 lines
606 B
C#

using System.Reflection;
namespace Speckle.Autofac;
public static class AssemblyResolver
{
public static Assembly? OnAssemblyResolve<T>(object? sender, ResolveEventArgs args)
{
// POC: tight binding to files
string name = args.Name.Split(',')[0];
string? path = Path.GetDirectoryName(typeof(T).Assembly.Location);
if (path == null)
{
return null;
}
string assemblyFile = Path.Combine(path, name + ".dll");
Assembly? assembly = null;
if (File.Exists(assemblyFile))
{
assembly = Assembly.LoadFrom(assemblyFile);
}
return assembly;
}
}