title: Visual C++ project developed in Visual C++ 2005 - In Visual C++ 2010, debug assertion fails on menu open, but release mode works, how to fix?
body: <p>I just started working on a project that was developed in Visual C++ 2005 using MFC, by someone else. To do so, I installed Visual C++ 2010 - I have no experience using either version (or visual studio at all, for that matter).</p>
  
  <p>The application has a menu bar that is implemented using the <code>CMenu</code> class, and is initialized from a resource (ie, is created using the menu editor).</p>
  
  <p>If I run the application in debug mode, the following debug assertion fails as soon as I open any menu in the menu bar:</p>
  
  <p>Filename: <code>afxwin1.inl</code></p>
  
  <p>Assertion (with appropriate context):</p>
  
  <pre><code>
  
      _AFXWIN_INLINE HMENU CMenu::GetSafeHmenu() const
          { ASSERT(this == NULL || m_hMenu == NULL || ::IsMenu(m_hMenu));
              return this == NULL ? NULL : m_hMenu; }
  
  </code></pre>
  
  <p>According to the debugger, <code>this</code> is set to a pointer to my menu, and <code>this-&gt;m_hMenu</code> is set to a pointer as well - however, the debugger seems to be confused about the type, the value is <code>0xdeadbeef {unused=??? }</code> (for a more boring value of <code>0xdeadbeef</code>, of course).</p>
  
  <p>It would seem that something is broken, and most likely in the project code - I am aware of this. However, if I create a release build, it runs without errors, and the menu is displayed correctly. Moreover, I edited the menu using the menu editor in Visual C++ 2010, and saved it - there was no change. I'm therefore ruling out menu compatibility issues from the resource being in the wrong format.</p>
  
  <p>I am running Windows XP SP3 on a ThinkPad T61p.</p>
  
  <p>The code that creates the menu is</p>
  
  <pre><code>
  
      CMenu menu;
      menu.LoadMenu(RESOURCE_NAME);
      SetMenu(&menu);
  
  </code></pre>
  
  <p>And runs in the context of a subclass of <code>CFrameWnd</code>.</p>
  
  <p>I have searched google a lot and am fairly certain that nobody had this problem before; Also, I'm a newbie to all of C++, MFC and Visual Studio. Help would be immensely appreciated; If I can provide more problem metadata, please tell me and I will do so.
  Thanks in advance!</p>