0
votes

I have an application that uses the MFC Ribbon. It is developed in Visual Studio 2010. I am facing a strange issue. The app works fine in Windows 7 and windows 2008 R2. However it crashes in windows 2008 when it tries to load the ribbon from resource. The exact line is

ribbonBar->LoadFromResource(IDR_RIBBON1); //IDR_RIBBON1 is the resource id.

The stack trace is below

gui.exe!ATL::CComPtrBase<IXMLDOMDocument>::~CComPtrBase<IXMLDOMDocument>()  Line 162 + 0xa bytes    C++
gui.exe!ATL::CComPtr<IXMLDOMDocument>::~CComPtr<IXMLDOMDocument>()  + 0x11 bytes    C++
gui.exe!ATL::CComQIPtr<IXMLDOMDocument,&_GUID_2933bf81_7b36_11d2_b20e_00c04f983e60>::~CComQIPtr<IXMLDOMDocument,&_GUID_2933bf81_7b36_11d2_b20e_00c04f983e60>()  + 0x11 bytes    C++
gui.exe!ATL::CXMLNode<IXMLDOMDocument>::~CXMLNode<IXMLDOMDocument>()  Line 47 + 0xb bytes   C++
gui.exe!ATL::CXMLDocument::~CXMLDocument()  Line 269 + 0x13 bytes   C++
gui.exe!CXMLParserRoot::~CXMLParserRoot()  Line 423 + 0x43 bytes    C++
gui.exe!CMFCRibbonInfo::Read(unsigned char * lpBuffer=0x013acb14, unsigned int nSize=83851)  Line 703 + 0x15 bytes  C++
gui.exe!CMFCRibbonInfoLoader::LoadFromBuffer(unsigned char * lpBuffer=0x013acb14, unsigned int nSize=83851)  Line 112 + 0x1b bytes  C++
gui.exe!CMFCRibbonInfoLoader::Load(const char * lpszResID=0x000005d8, const char * lpszResType=0x0000001c, HINSTANCE__ * hInstance=0x00400000)  Line 85 + 0x1c bytes    C++
gui.exe!CMFCRibbonBar::LoadFromResource(const char * lpszXMLResID=0x000005d8, const char * lpszResType=0x0000001c, HINSTANCE__ * hInstance=0x00000000)  Line 740 + 0x17 bytes   C++
gui.exe!CMFCRibbonBar::LoadFromResource(unsigned int uiXMLResID=1496, const char * lpszResType=0x0000001c, HINSTANCE__ * hInstance=0x00000000)  Line 731    C++

Any suggestions, advice as to how to go about this issue is greatly appreciated. Do, ask if you need more information.

2
It isn't very clear what the crash actually looks like. An access violation in a destructor call is almost always caused by heap corruption. That corruption wasn't caused by the ribbon control but by code that ran earlier.Hans Passant

2 Answers

2
votes

I know this answer is years late, but I just ran into your same problem while updating an old MFC application to support the Ribbon. What needed to be done in order for LoadResources to work correctly, was to call AfxOleInit() during InitInstance() in the App class. I do this before loading the MFC frame.

Hope this helps!

0
votes

Did you try to install redistributable package on deployed machine? It is possible that Windows (Server) 2008 R2 comes with Visual C++ 2010 Redistributable package and Windows Server 2008 not. Also take into account that if you updated Visual Studio to SP1 you should use redistributable package for SP1.