I came across a solution for loading an assembly in a script task using reflection such as this...
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name.Contains("ssisHelper"))
{
string path = @"c:\temp\";
return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "ssisHelper.dll"));
}
else if (args.Name.Contains("xxx"))
{
string path = @"c:\temp\";
return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "xxx.dll"));
}; return null;
That works great but my problem is that only works for one assembly. Is there a solution to load multiple assemblies?
I'm using Data Tools for Visual Studio 2015 and I'm trying to load two dlls that I can't add to a GAC. I'm using the 4.0 framework but I can go as high as 4.6.1 if need be.
Edit: Just in case it needs to be mentioned, The AssemblyResolve
event handler can only be called once when the program starts. I call by
appDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);