NullReferenceException in FtpDLX.PutFile (wodFtpDLX / wodFtpDLX.NET)

by Kurt @, (34 days ago)

Hi there

Following code works usually fine. In very rare cases it leads to a NullReferenceException inside of the PutFile call at a customer installation for no obvious reasons. We're using Version 1.8.3.247. Thanks for any hints.

Here's the exception:

System.NullReferenceException: Object reference not set to an instance of an object.
at A.a.n()
at WeOnlyDo.Client.FtpDLX.PutFile(String LocalFile, String RemotePath)

Here's the code. In reality filename changes each time:

using WeOnlyDo.Client;

string filename = "Test.pdf";
string localdir = @"C:\temp\";
string remotedir = @"/Upload/";

using (var ftp = new FtpDLX())
{
ftp.LicenseKey = "#####";

// We don't want to do complex event handling.
ftp.Blocking = true;

ftp.Protocol = Protocols.FTP;
ftp.Hostname = "#####";
ftp.Port = 21;
ftp.Authentication = Authentications.Password;
ftp.Login = "#####";
ftp.Password = "#####";
ftp.Passive = false;
ftp.KeepAlive = 0;
ftp.Timeout = 0;
ftp.Resume = false;

ftp.Connect();

ftp.Timeout = 0;
ftp.ListNames(remotedir);

List<string> files = new List<string>();
foreach (string file in ftp.ListItem.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
{
files.Add(file.ToLowerInvariant());
}

if (!files.Contains(filename.ToLowerInvariant()))
{
ftp.CheckDir(remotedir);
ftp.PutFile(Path.Combine(localdir, filename), remotedir + filename);
}
}

NullReferenceException in FtpDLX.PutFile

by Jasmine, (30 days ago) @ Kurt

Somehow we missed this post, sorry.
Any chance we can duplicate this issue? "sometimes" isn't helpful, we need to isolate and see why/when this happens.

Thanks,
Jasmine

NullReferenceException in FtpDLX.PutFile

by Kurt @, (29 days ago) @ Jasmine

Hi Jasmine

Since 2023 we've connected 962 times to the same SFTP Server to upload files and two times it failed with said NullReferenceException. Once in September 2024 and once last week.

It's not a big deal. If an error occurs, we retry the upload a short while after and then it worked both times. I just thought that maybe you could find a source for a NullReferenceException in that A.a.n() method, which I can't inspect. But if that's not possible, it's ok. We just ignore that error from now on.

Kind Regards,
Kurt

NullReferenceException in FtpDLX.PutFile

by Jasmine, (29 days ago) @ Kurt

Hi,
I'm affraid we can't do it that way. Also, I see you use very old version, it's possible this issue is fixed in the meantime. But such exception can in theory happen for 1000 reasons.

If this becomes a problem, let me know and we'll try to see for a way to duplicate it.

Regards,
Jasmine