manatttta
manatttta

Reputation: 3130

MFC Assertion error when calling function from DLL

I am calling this functions from a DLL context,

void CmodguiApp::ReportStatusBarImageCount() {

CMainFrame *frm = nullptr;
auto app = AfxGetApp();
if (nullptr != app) {
     frm = (CMainFrame*)app->GetMainWnd();
}

assert(frm);

frm->setStatusBarImageCount(L"Text");

}

Everything is OK. frm is NOT a nullptr.

Then, inside setStatusBarImageCount, which is described below, the software causes an assertion error

What could be wrong?

void CMainFrame::setStatusBarImageCount(const wchar_t *str) {

     m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_STATUSBAR_IMAGECOUNT), str);

}

This app has MFC dynamically linked. Please let me stress that the setStatusBarImageCount function is called from within a DLL, and not from the main MFC app.

assertion error

Upvotes: 0

Views: 561

Answers (1)

manatttta
manatttta

Reputation: 3130

This was because I was calling the MFC API from a custom thread (https://msdn.microsoft.com/en-us/library/975t8ks0.aspx)

This shall be done using custom message implementations, which is thread safe (https://msdn.microsoft.com/en-us/library/k35k2bfs.aspx)

Upvotes: 1

Related Questions