Under the assumption that you are linking the MFC statically:
Solution
Put
#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS
at the top of your stdafx.h
, or add _AFX_NO_MFC_CONTROLS_IN_DIALOGS
to the preprocessor definitions in the project settings.
Explanation
MSVC 2010 contained a large number of new, extended controls (most of them related to ribbons, but also a CMFCButton
and other things. There was also a feature pack for MSVC 2008). These new controls can be added to a dialog through the resource editor just like the old Windows controls.
In order to make this work, the code that parses your RC file1 needs to know all the new MFC control classes. This is not a problem if you link the MFC dynamically, but if you link them statically, it means that all the shiny new parts of the MFC are linked into your application whether you use them or not. I had a binary triple in size because of this.
Fairly quickly, this turned out to be a bigger problem than the people at Microsoft had imagined; linking the MFC statically is apparently more common than they expected. Working around the problem in MSVC 2010 remains painful, but with the next version, a mechanism was introduced to disable the new functionality: the _AFX_NO_MFC_CONTROLS_IN_DIALOGS
preprocessor macro. If it is defined before any inclusion of MFC headers, the RC parser code does not handle the new controls, and a dependency to them is not introduced. Note that this means that the new controls cannot be added to dialogs through the resource editor.
A more detailed technical description of the problem and solution can be found in this MSDN blog post.
1Yes, I'm glossing over some detail here.