Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8426289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:30:19+00:00 2026-06-10T04:30:19+00:00

An exception is thrown in the finally block containing the line response.Close(); try {

  • 0

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

enter image description here

(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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:30:20+00:00Added an answer on June 10, 2026 at 4:30 am

    I would check also if the stream is still readable.

           finally
            {
                if (response != null && 
                     response.GetResponseStream()!=null && 
                     response.GetResponseStream().CanRead)
                    {
                        response.Close();
                    }
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

does try/catch affects performance if no exception thrown in try block? how about try/catch/finally
If I am using a try/catch/finally block where and how should I initialize variables?
A RuntimeException is thrown in try block without being caught, while the finally clause
try { // Do stuff } catch (Exception e) { throw; } finally {
Possible Duplicate: In C# will the Finally block be executed in a try, catch,
Possible Duplicates: Conditions when finally does not execute in a .net try..finally block In
Try xConn.ConnectionString = xConnBuilder.ConnectionString xConn.Open() Throw New Exception(Something) Catch ex As Exception Throw Finally
When an exception is thrown or encountered: void ThrowException() { try { throw new
If a finally block throws an exception, what exactly happens? Specifically, what happens if
I'm having a problem understanding the order of execution for the try-catch-finally. All the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.