-3

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;
}
17
  • 3
    Can you show at least the relevant parts of the dialog template resource script that fails creation? Commented Nov 18 at 23:02
  • 4
    As a sanity check, open the EXE file in Resource Editor and confirm that the DIALOG resource is actually present. File > Open > File, select the EXE, click the down-arrow next to Open button, click Open With, and select Resource Editor. Commented Nov 19 at 0:04
  • 1
    @solarflare Sometimes it also surprises me, but on the other hand software can have life cycles spanning multiple decades or more too :) Commented Nov 19 at 5:02
  • 2
    I would not trust an MFC function to retain the relevant GetLastError() value. Better use the debugger to step into DoModal(). You have to disable "Just my code" in the settings. Commented Nov 19 at 7:36
  • 2
    Well, at least now you know what to look for. Perhaps the .rc file is somehow not part of the build. Or it fails to compile with some error. As a quick check, type some random garbage into the .rc file and see if you get an error pointing to that garbage (if not, the file isn't even being compiled). Commented 2 days ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.