Reputation: 6745
I am trying to load a dll in a SSIS project that ins't in a GAC. I followed the following code from here
the code:
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
static ScriptMain()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}
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"));
}
return null;
}
}
This enabled the loading of the dll but it keep giving me the following error because Entity Framework was referenced inside the dll.
Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
So I tried to set the Working directory of dll with no success because dll's don't have an entry point. So I got the idea to put the file in a console application from here. I built an .exe and changed it to a .dll. Now in theory I have an entry point where I could set the working directory.
System.Environment.CurrentDirectory = @"PathToDll";
Yet I still get the same error. Does any one know of a solution?
Upvotes: 1
Views: 3165
Reputation: 37348
Try to add an else if clause for each Assembly name:
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;
Upvotes: 1