VS6 to VS2012 migration causes "Error: no data exchange control with ID" in OninitDialog() RRS feed

  • Question

  • I'm migrating a MFC project from VS6 to VS2012. When I click on a button in one my screens in application, it tries to load a dialog. That dialog contains checkbox, radio button, text box. But its crashing at dlgdata.cpp indicating that - Error: no data exchange control with ID. This is happening when OninitDialog() is being called for that dialog. I checked the .rc file and the ID exists. Also checked for duplicate IDs, there are no duplicates. But the same code works fine in VS6 w/o  any errors. But this crash is happening only in VS2012 after migration. Pls advise.

    Thanks and Regards


    Tuesday, March 12, 2013 12:46 PM

All replies

  • The ID that is failing comes from a DDX call in the dialog's DoDataExchange function. Have you checked the IDs there for spelling, capitalization, exact match with the .rc file  ...  ?

    Tuesday, March 12, 2013 4:13 PM
  • Yes its exactly matching and its working fine in VS6 (Win XP OS). But its crashing in VS2012 (Win 7 OS).
    Wednesday, March 13, 2013 5:34 AM
  • If all ID are there and are correct in your DoDataExchange function than I'd say you place a breakpoint at the very fist line of your DoDataExchange function, and also your OnInitdialog function, and than step the functions.

    In the first try I'd step all DDX/DDV in the DoDataExchange function. If everything is working there than I'd try to look in OnInitdialog, ...

    Best regards


    Note: Posted code pieces may not have a good programming style and may not perfect. It is also possible that they do not work in all situations. Code pieces are only indended to explain something particualar.

    Wednesday, March 13, 2013 5:43 AM
  • Yes, its crashing at OnInitDialog(). It goes till PrepareCtrl() which throws up the error message.

     m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl);
     if (hWndCtrl == NULL) //hWndCtrl is NULL for me here
      // Could be a windowless OCX
      pSite = m_pDlgWnd->GetOleControlSite(nIDC); //pSite is also NULL for me here
      if (pSite == NULL)
       TRACE(traceAppMsg, 0, "Error: no data exchange control with ID 0x%04X.\n", nIDC);


    I'm testing this on Windows 7 PC.
    • Edited by ckarpagam Wednesday, March 13, 2013 1:31 PM
    Wednesday, March 13, 2013 1:31 PM
  • Before calling DoModal(), AFX_MANAGE_STATE(AfxGetStaticModuleState()); needs to be called.
    Friday, March 22, 2013 2:27 PM
  • So, is your Dialog in a dll?  I'm having this same problem, but can't use the call you suggest, because my (CDialog based) dialog isn't in a dll... 

    Friday, June 14, 2013 9:27 PM
  • MesaMike, you are right that Afx_MANAGE_STATE is relevant only if the dialog is in a DLL. Follow the steps suggested in the earlier answers to narrow down the problem.
    Saturday, June 15, 2013 1:58 AM
  • Can you upload a repro or a memory dump somewhere and share it with us?


    Posts are provided as is without warranties or guaranties.

    Saturday, June 15, 2013 3:15 PM