我有一个 GUI 应用程序MFC
。出于某种原因,它在 Visual Studio 发布和调试模式下工作得非常好,但如果.exe
双击启动它会崩溃。
我不明白这个错误可能在哪里,因为它在 Visual Studio 中托管时工作得很好。无奈之下,我禁用了所有优化例程,但似乎没有帮助。
OS
是Win 7
,IDE
是VS 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
为 throw 以捕获任何已处理的异常,并将其设置afxAmbientActCtx
为FALSE
,但没有运气让它运行。这exe
以前运行得很好。
好心提醒。