An exception is thrown in the finally block containing the line response.Close();
try
{
response = (FtpWebResponse)request.GetResponse();
}
catch (System.Net.WebException webEx)
{
FtpWebResponse ftpResponse = (FtpWebResponse)webEx.Response;
if (ftpResponse.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
{
return false;
}
throw;
}
finally
{
if (response != null)
{
response.Close();
}
}
Heres the stacktrace:
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.Stream.Dispose()
at System.Net.ConnectionPool.Destroy(PooledStream pooledStream)
at System.Net.ConnectionPool.PutConnection(PooledStream pooledStream, Object owningObject, Int32 creationTimeout, Boolean canReuse)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.CommandStream.CheckContinuePipeline()
at System.Net.FtpWebRequest.DataStreamClosed(CloseExState closeState)
at System.Net.FtpDataStream.System.Net.ICloseEx.CloseEx(CloseExState closeState)
at System.Net.FtpDataStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.Net.FtpWebResponse.Close()
at FVC.RequestForStock.Application.RequestForStockDataImportProvider.VerifyDirectoryExist(String serverAddress, String userName, SecureString password) in C:\CoName.RFS.Application\RFSDataImportProvider.cs:line 122
And lastly what the debug inspector shows

(Zoom in on the picture if you can’t make out the text e.g. in firefox hold down ctrl and roll the mouse wheel up)
Could someone please assist in identifying why the exception occurs and how to possibly prevent it.
EDIT: Using v4.0 of the Microsoft.NET framework
I would check also if the stream is still readable.