I used WinDbg tool to find out where the problem is and it showed the
problem in myodbc3.dll, I am using MySQL database. So I commented out
everything relted to the database and it gave no problems. I also created
a
new dialog based application where I just open the database in the OnInit
dialog() and close the database in OnClose().
BOOL CTryDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
if (!TelexDB.IsOpen())
{
/********added code ***************/
try
{
TelexDB.Open( "VoiceStore",FALSE,FALSE,"ODBC;UID=root;PWD=",FALSE );
}
catch(...)
{
MessageBox("Failed To Connect To Database","Error",
MB_OK|MB_ICONINFORMATION) ;
}
}
/**************End of added code ************/
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CTryDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
if (TelexDB.IsOpen())
{
TelexDB.Close();
}
CDialog::OnClose();
}
It doesnt show any compiler errors. While using WinDbg and when I close
the
application it gives this error. I am guessing there is either a problem
in
the way I am opening and closing the database or there is a bug in
myodbc3.dll.
Please let me know your comments.
<avrf:message>Unloading DLL containing an active critical
*****
THis looks deadly right here. At this point, you need to figure out why
you are unloading
a DLL that has an active critical section! Until this is solved, there
isn't much else to
discuss. I would not at all be surprised if that bizarre attempt to shut
down the threads
was malfunctioning and led to this situation.
You need to resolve all threading issues first. I can think of a whole
bunch of things
that code like this can lead to, none of them good. You need to rewrite
the shutdown
sequence and make it an asynchronous shutdown sequence. Otherwise, you
are going to
continue to be plagued with problems.
*****
section.</avrf:message>
<avrf:parameter1>10103944 - Critical section
address.</avrf:parameter1>
<avrf:parameter2>0 - Critical section initialization stack
trace.</avrf:parameter2>
<avrf:parameter3>1730fe8 - DLL name address.</avrf:parameter3>
<avrf:parameter4>10000000 - DLL base address.</avrf:parameter4>
- <avrf:stackTrace>
<avrf:trace>vfbasics!VfBasicsStopMessage+8e</avrf:trace>
<avrf:trace>vfbasics!AVrfpFreeMemLockChecks+17c</avrf:trace>