Hi all,
This is my problem:

void StartRun( void )
{
    std::auto_ptr<Validate> val ( new Validate( "input.txt" ) );
    val->DoIt( );
}
// Destructor
Validate::~WValidate( )
{
  if( mFileIn.is_open())
  {
    mFileIn.close();
  }
  if( mFileOut.is_open() )
  {
    mFileOut.flush();
    mFileOut.close();
  }
}

The function DoIt() makes use of a DLL. Now heres the problem:
When there is an exception thrown by the DLL, I should say the
mFileOut should always be closed but it doesn't. I can't delete
the outputfile until I close my application because it says the
file is still open.
It only closes in the 'Debug Build' but not in the 'Release Build'.
Anyone has an idea ??
I use the Borland Developer Studio 2006.

My guess is that your program is crashing sooooo bad that the destructor is not getting called, the program is just dumping back to the os without doing any cleanup. You really need to find out what is causing the exception and fix it. Lacking that you should implement exceptions (try/catch blocks) as ithelp suggested.

My guess is that your program is crashing sooooo bad that the destructor is not getting called, the program is just dumping back to the os without doing any cleanup. You really need to find out what is causing the exception and fix it. Lacking that you should implement exceptions (try/catch blocks) as ithelp suggested.

The try/catch block is already implemented in the DoIt function but that's not the solution because the exception is caused by a third party DLL.
It's still a fact that in the 'Debug Build' the destructor is called, and the file can be deleted, but in the 'Release Build' it isn't.
So suggestions are still welcome....

The try/catch block is already implemented in the DoIt function but that's not the solution because the exception is caused by a third party DLL.

Talk to the third party. They have a better chance of figuring out what's going wrong.

This article has been dead for over six months. Start a new discussion instead.