ArgumentNullException: Value cannot be null. Parameter name: path1



ArgumentNullException: Value cannot be null. Parameter name: path1

This is my code on c#

string server = ConfigurationManager.AppSettings["server"];
string user = ConfigurationManager.AppSettings["user"];
string password = ConfigurationManager.AppSettings["password"];
string pathToFolder = ConfigurationManager.AppSettings["pathToFolder"];
SessionOptions options = new SessionOptions();
options.HostName = server;
options.Password = password;
options.Protocol = Protocol.Scp;
options.Timeout = TimeSpan.FromSeconds(20);
options.UserName = user;
options.SshHostKeyFingerprint = ""; //I don't use security code
using (WinSCP.Session session = new WinSCP.Session())
// Connect

// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;

TransferOperationResult transferResult;
transferResult = session.PutFiles(@"d:\toupload\*", "/home/user/", false, transferOptions);

// Throw on any error

// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
return true;
catch (Exception ex)
return false;

My application works on mono/linux and I don't use security code

Exception throws when I try to open session.

Reply with quote


Site Admin
martin avatar
Prague, Czechia

Re: ArgumentNullException: Value cannot be null. Parameter name: path1

Please attach a full exception callstack and full debug log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.DebugLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote


Having the same issue

Here's the exception stack

Value cannot be null.
Parameter name: path1 (Occurrences: <1>, TrackingId: <2ca09af9-c780-4017-a1ab-c1d36610384f>)

The following exception occurred:

General Information
Additional Info:
TrackingId: 912727d7-c1cd-4e1e-89aa-278bd54078d4
Time (UTC): 04/15/2019 18:51:41
MachineName: d98552119a9f
UTC: 04/15/2019 18:51:41

1) Exception Information
Exception Type: System.ArgumentNullException
Message: Value cannot be null. Parameter name: path1
ParamName: path1
Data: System.Collections.ListDictionaryInternal
TargetSite: System.String Combine(System.String, System.String)
HelpLink: NULL
Source: System.Private.CoreLib
HResult: -2147467261

StackTrace Information
at System.IO.Path.Combine(String path1, String path2)
at WinSCP.ExeSessionProcess.GetExecutablePath()
at WinSCP.ExeSessionProcess..ctor(Session session, Boolean lLog, String additionalArguments)
at WinSCP.Session.Open(SessionOptions sessionOptions)
at Scs.Lms.ActivityWatcher.Core.FileSystems.FtpConnection.EstablishAsync() in C:\Github\iherb\scs\lms\lms.activity.watcher\src\ActivityWatcher.Core\FileSystems\FtpConnection.cs:line 40
at Scs.Lms.ActivityWatcher.Core.FileSystems.FtpFileSystem.GetFilesAsync(String root, String searchPattern) in C:\Github\iherb\scs\lms\lms.activity.watcher\src\ActivityWatcher.Core\FileSystems\FtpFileSystem.cs:line 59
at Scs.Lms.ActivityWatcher.Processor.ServiceProcessor.ProcessAsync(CancellationToken cancellationToken) in C:\Github\iherb\scs\lms\lms.activity.watcher\src\ActivityWatcher.Processor\ServiceProcessor.cs:line 89
at Scs.Lms.ActivityWatcher.Core.SparkHost.SparkHostService.DoWorkAsync(CancellationToken cancellationToken) in C:\Github\iherb\scs\lms\lms.activity.watcher\src\ActivityWatcher.Core\SparkHost\SparkHostService.cs:line 89

Reply with quote


You can post new topics in this forum