I have a massive C++14, Win32 project that uses legacy MFC. So far, project compiles and works fine at Platform Toolset v142 (vs2019) and latest Windows 10 SDKs.
However, when I set the Platform Toolset to either v143 (2022) or v145, it also compiles without errors or warning, but the CDialog::DoModal() call returns -1.
A call to GetLastError() returns ERROR_RESOURCE_TYPE_NOT_FOUND (1813).
Spent many hours debugging, it seems to be a problem with resource loading. I do have other legacy projects with same build and project configurations that compiles and runs fine with vs145.
I'm completely lost on this!
BOOL CServerApp::InitInstance()
{
CWinApp::InitInstance();
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
CWServerDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == -1)
{
DWORD dwError = GetLastError();
TRACE("DoModal failed with error: %d\n", dwError);
AfxMessageBox(CString("Error: ") + CString(std::to_string(dwError).c_str()));
}
if (nResponse == IDOK)
{
// TODO:
}
else if (nResponse == IDCANCEL)
{
// TODO:
}
return FALSE;
}
File > Open > File, select the EXE, click the down-arrow next toOpenbutton, clickOpen With, and select Resource Editor.GetLastError()value. Better use the debugger to step intoDoModal(). You have to disable "Just my code" in the settings.