Discuss (FTP), (FTP on .NET CF) and (FTPS, SFTP and SCP).
no avatar
User

TimNZ

Posts

3

Joined

Wed Sep 28, 2011 1:44 pm

NullReferenceException in FTPConnection.DownloadByteArray

by TimNZ » Wed Sep 28, 2011 1:55 pm

Hi,

(Great component, thanks for the Freebie!)

I get a NullReferenceException when the file does not exist. Having quickly looked through the source and even attached the src project and debugged,
an FTPException is obviously what I should be getting and is what is thrown when I step through the edtFTP src. But via the Finally it looks like something is broken.

Sample code and stack trace below.

Output:
A first chance exception of type 'EnterpriseDT.Net.Ftp.FTPException' occurred in edtFTPnet.DLL
A first chance exception of type 'EnterpriseDT.Net.Ftp.FTPException' occurred in edtFTPnet.DLL
A first chance exception of type 'EnterpriseDT.Net.Ftp.FTPException' occurred in edtFTPnet.DLL
A first chance exception of type 'System.NullReferenceException' occurred in edtFTPnet.DLL

public byte[] GetFileData(PathInfo pathInfo)
{
byte[] data = null;
using (FTPConnection conn = GetConnection(pathInfo))
{
try
{
conn.ChangeWorkingDirectory(pathInfo.Directory);
data = conn.DownloadByteArray(pathInfo.Filename);
return data;
}
catch (FTPException ex)
{

}
return data;
}
}


System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=edtFTPnet
StackTrace:
at EnterpriseDT.Net.Ftp.FTPConnection.OnDownloaded(Byte[] bytes, String remoteFile, Int64 bytesTransferred, Exception ex, Int64 remoteFileSize, DateTime remoteModTime)
at EnterpriseDT.Net.Ftp.FTPConnection.DownloadByteArray(String remoteFile)
at A.ClientLibrary.FileManagement.FTPFileManager.GetFileData(PathInfo pathInfo) in C:\Development\Projects\FileManager.cs:line 269
at A.ClientLibrary.FileManagement.FileManager.GetFileData(String path) in C:\Development\Projects\FileManager.cs:line 39
at A.Program.Main(String[] args) in C:\Development\Test\MockGenClientLibraryTest\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: NullReferenceException in FTPConnection.DownloadByteArra

by support2 » Thu Sep 29, 2011 8:49 am

I think that's a bug we've fixed recently. Email support@... for the latest build (not yet released).
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: NullReferenceException in FTPConnection.DownloadByteArra

by support2 » Thu Sep 29, 2011 4:11 pm

Actually the fix I'm thinking of is in the latest release, 2.2.2. Are you using it?

If not, upgrade. If you are please send us a log file at the Debug level.
no avatar
User

TimNZ

Posts

3

Joined

Wed Sep 28, 2011 1:44 pm

by TimNZ » Fri Sep 30, 2011 1:29 pm

no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Fri Sep 30, 2011 10:35 pm

no avatar
User

TimNZ

Posts

3

Joined

Wed Sep 28, 2011 1:44 pm

by TimNZ » Sun Oct 02, 2011 7:36 am

no avatar
User

i9magol

Posts

1

Joined

Mon Jan 09, 2012 10:49 pm

by i9magol » Mon Jan 09, 2012 10:54 pm

no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Tue Jan 10, 2012 7:26 am


Who is online

Users browsing this forum: No registered users and 28 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign