Differences
This shows you the differences between the selected revisions of the page.
2022-12-08 | 2022-12-08 (current) | ||
System.IO for File (martin) | no actual "installation" is needed (except for GAC, which mentioned explicitly numerous times throughout the article) + more emphasis on the AssemblyResolve approach (martin) | ||
Line 2: | Line 2: | ||
===== [[installing]] Installing ===== | ===== [[installing]] Installing ===== | ||
- | First, you need to [[library_install|install the WinSCP .NET assembly]]. Do not use the NuGet package.((See [[https://stackoverflow.com/q/55457058/850848|How to fix NuGet WinSCP.NET in SSIS Script Task?]])) | + | First, you need to [[library_install|download the WinSCP .NET assembly]]. Do not use the NuGet package.((See [[https://stackoverflow.com/q/55457058/850848|How to fix NuGet WinSCP.NET in SSIS Script Task?]])) |
- | You also need to [[library_install#gac|install the assembly to the GAC]] or [[#subscribe|subscribe ''AppDomain.AssemblyResolve'' event]] to allow loading the assembly. | + | You also need to [[library_install#gac|install the assembly to the GAC]] or [[#subscribe|subscribe ''AppDomain.AssemblyResolve'' event]] in your code to allow loading the assembly. |
===== [[using]] Using from SSIS ===== | ===== [[using]] Using from SSIS ===== | ||
Line 15: | Line 15: | ||
* Use //Project > Add Reference > Browse// to add reference to ''winscpnet.dll''; | * Use //Project > Add Reference > Browse// to add reference to ''winscpnet.dll''; | ||
* Place your C# or VB.NET code into ''ScriptMain.Main'' method (see the example below); | * Place your C# or VB.NET code into ''ScriptMain.Main'' method (see the example below); | ||
+ | * If you have chosen the GAC approach, you need to [[library_install#installing|set ''Session.ExecutablePath'']]. Alternatively, [[#subscribe|subscribe ''AppDomain.AssemblyResolve'' event]]. | ||
* Close Visual Studio of the script project. Close //Script Task Editor// with //OK// button. | * Close Visual Studio of the script project. Close //Script Task Editor// with //OK// button. | ||
Line 53: | Line 54: | ||
using (Session session = new Session()) | using (Session session = new Session()) | ||
{ | { | ||
- | // As WinSCP .NET assembly has to be stored in GAC to be used with SSIS, | + | // If WinSCP .NET assembly has been stored in GAC to be used with SSIS, |
- | // you need to set path to WinSCP.exe explicitly, | + | // you need to set path to WinSCP.exe explicitly. |
- | // if using non-default location. | + | // This is not needed if you have subscribed AppDomain.AssemblyResolve event |
+ | // and the WinSCP.exe is in the same location as WinSCPnet.dll. | ||
session.ExecutablePath = @"C:\winscp\winscp.exe"; | session.ExecutablePath = @"C:\winscp\winscp.exe"; | ||