I can not use a specific DLL in SSIS script-task. In c# console-project anything is fine. SSIS throws the error:
Error: The Type "Microsoft.SharePoint.Client.ClientRuntimeContext" in assembly "Microsoft.SharePoint.Client, Version=14.0.0.0, Culture=neutral PublicKeyToken=...." could not be loaded.
I am running Visual Studio 2017 with Datatools. I got the libraries from NuGet-paket-manager and saved them local on C:/
- Microsoft.SharePoint.Client, Version 14.0.0.0, Runtime-Version v2.0.50727
- Microsoft.SharePoint.Client.Runtime, Version 15.0.0.0, Runtime-Version v4.0.30319
My console-project is .NET 4.6 and i ve setted the SSIS project also to .NET 4.6. In both cases I added the libraries with rightclick on References > Add > Search from computer
I just tested a console-project without any problems:
static void Main(string[] args)
{
using (ClientContext clientContext = new ClientContext("urltomysite.com"))
{
}
Console.WriteLine("finished");
}
And this is the code in SSIS (it is similar... Just uses the object ClientContext:
public void Main()
{
//Loading assemblies extra
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve2);
try
{
//Testing the assembly method
Class1.TESTIT();
}
catch (Exception ex)
{
Dts.Events.FireError(0, "Error", ex.Message, null, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine("C:/", "Microsoft.SharePoint.Client.dll"));
}
static System.Reflection.Assembly CurrentDomain_AssemblyResolve2(object sender, ResolveEventArgs args)
{
return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine("C:/", "Microsoft.SharePoint.Client.Runtime.dll"));
}
class Class1
{
public static void TESTIT()
{
using (ClientContext clientContext = new ClientContext("urltomysite.com"))
{
}
}
}