Differences
This shows you the differences between the selected revisions of the page.
| 2014-06-23 | 2015-06-24 | ||
| deploying (martin) | Adding information about assembly location redirection (tsaukpaetra) | ||
| Line 19: | Line 19: | ||
| ===== Deploying WinSCP .NET Assembly ===== | ===== Deploying WinSCP .NET Assembly ===== | ||
| - | When deploying your SSIS package, WinSCP .NET assembly needs to be [[library_install#gac|installed to GAC]] to be accessible. | + | When deploying your SSIS package, WinSCP .NET assembly should be [[library_install#gac|installed to GAC]] to be accessible. |
| + | It is possible to redirect the assembly elsewhere, however the location must be accessible by the user that the package is running as, and a Static Constructor handler needs to be attached inside the script (See [[http://blogs.msdn.com/b/dbrowne/archive/2014/06/25/how-to-load-an-assembly-in-a-ssis-script-task-that-isn-t-in-the-gac.aspx|This MSDC blog article]] for more detailed information). | ||
| + | |||
| + | Some sample code (Add inside the class): | ||
| + | public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase | ||
| + | { | ||
| + | static ScriptMain() | ||
| + | { | ||
| + | AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); | ||
| + | //The rest of your code | ||
| + | } | ||
| + | static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) | ||
| + | { | ||
| + | if (args.Name.Contains("winscpnet.dll")) | ||
| + | { | ||
| + | string path = @"c:\temp\"; | ||
| + | return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "winscpnet.dll")); | ||
| + | } | ||
| + | return null; | ||
| + | } | ||
| + | } | ||
| ===== [[example]] Example C# Script Task Code ===== | ===== [[example]] Example C# Script Task Code ===== | ||