MFC应用程序在Visual Studio中工作,但双击启动崩溃

时间:2015-06-25 04:53:13

标签: c++ visual-studio-2010 mfc crash ntdll

我在MFC中有一个GUI应用程序。出于某种原因,它在Visual Studio Release和Debug模式下运行得非常好,但如果通过双击启动.exe,则会崩溃。

我无法理解这个错误的位置,因为它在Visual Studio中托管时工作得很好。无奈之下,我禁用了所有优化例程,但它似乎没有帮助。

OSWin 7IDEVS 2010

错误模块是ntdll.dll,但我怀疑这是真正的问题......

编辑 -

将调试程序附加到崩溃显示LoadFrame()

出现问题
BOOL CAAUserInterfaceDllConsumerApp::InitInstance()
{
    // InitCommonControlsEx() is required on Windows XP if an application
    // manifest specifies use of ComCtl32.dll version 6 or later to enable
    // visual styles.  Otherwise, any window creation will fail.
    INITCOMMONCONTROLSEX InitCtrls;
    InitCtrls.dwSize = sizeof(InitCtrls);
    // Set this to include all the common control classes you want to use
    // in your application.
    InitCtrls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&InitCtrls);

    CWinAppEx::InitInstance();


    EnableTaskbarInteraction(FALSE);

    // AfxInitRichEdit2() is required to use RichEdit control   
    // AfxInitRichEdit2();

    // Standard initialization
    // If you are not using these features and wish to reduce the size
    // of your final executable, you should remove from the following
    // the specific initialization routines you do not need
    // Change the registry key under which our settings are stored
    // TODO: You should modify this string to be something appropriate
    // such as the name of your company or organization
    SetRegistryKey(_T("Local AppWizard-Generated Applications"));

    DWORD isApprunning = 0;

    m_hStartMutex = CreateSemaphore(NULL,
                                    1,
                                    1,
                                    _T("Something"));

    if (GetLastError() ==  ERROR_ALREADY_EXISTS)
    {
        // I dont want to start !
        return FALSE;
    }

    InitContextMenuManager();

    InitKeyboardManager();

    InitTooltipManager();
    CMFCToolTipInfo ttParams;
    ttParams.m_bVislManagerTheme = TRUE;
    theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
        RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

    // To create the main window, this code creates a new frame window
    // object and then sets it as the application's main window object
    CMainFrame* pFrame = new CMainFrame;
    if (!pFrame)
        return FALSE;
    m_pMainWnd = pFrame;
    // create and load the frame with its resources
    pFrame->LoadFrame(IDR_MAINFRAME,
        WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
        NULL);
      .//more stuff
}

这叫:

BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) 
{
    // base class does the real work

    //if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext))
    if (!CFrameWndEx::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext))
    {
        return FALSE;
    }

这是它在Visual Studio之外失败的地方。

给出的例外是:The activation context being deactivated is not the most recently activated one

我四处搜索并尝试了以下操作,即设置所有Exceptions以捕获任何已处理的异常,并将afxAmbientActCtx设置为FALSE,但没有运气让它运行。这个exe以前运行得很好。

请告知。

0 个答案:

没有答案