C++ MRISegmentation.exe中0x0435A072(mfc110d.dll)处的首次机会异常:0xC0000005:访问冲突读取位置0x00000000

C++ MRISegmentation.exe中0x0435A072(mfc110d.dll)处的首次机会异常:0xC0000005:访问冲突读取位置0x00000000,c++,visual-studio,mfc,C++,Visual Studio,Mfc,我已将visual studio 10程序转换为visual studio 12。程序构建成功,但当我尝试运行它时。如果(!pThread->InitInstance())在这里出现错误。pThread为空 我试着从它被称为的地方寻找它。但我不知道每次我试着调试它时,它都会直接转到winmain.cpp并得到pThread null错误。我在这里发布我的主文件和头文件的代码 #include "stdafx.h" #include "MRISegmentation.h" #include "MR

我已将visual studio 10程序转换为visual studio 12。程序构建成功,但当我尝试运行它时。如果(!pThread->InitInstance())在这里出现错误。pThread为空

我试着从它被称为的地方寻找它。但我不知道每次我试着调试它时,它都会直接转到winmain.cpp并得到pThread null错误。我在这里发布我的主文件和头文件的代码

#include "stdafx.h"
#include "MRISegmentation.h"
#include "MRISegmentationDlg.h"

 #ifdef _DEBUG
 #define new DEBUG_NEW
 #endif


     // CMRISegmentationApp

 BEGIN_MESSAGE_MAP(CMRISegmentationApp, CWinApp)
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  END_MESSAGE_MAP()


 // CMRISegmentationApp construction

 CMRISegmentationApp::CMRISegmentationApp()
  {


// TODO: add construction code here,
// Place all significant initialization in InitInstance
}


// The one and only CMRISegmentationApp object

CMRISegmentationApp theApp;

// CMRISegmentationApp initialization

BOOL CMRISegmentationApp::InitInstance()

{    
InitCommonControls();

CWinApp::InitInstance();

AfxEnableControlContainer();
// 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"));

CMRISegmentationDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
    // TODO: Place code here to handle when the dialog is
    //  dismissed with OK
}
else if (nResponse == IDCANCEL)
{
    // TODO: Place code here to handle when the dialog is
    //  dismissed with Cancel
}

// Since the dialog has been closed, return FALSE so that we exit the
//  application, rather than start the application's message pump.
return FALSE;
 }

 And the header file  "MRISegmentation.h" is below

 #pragma once

#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h"       // main symbols


// CMRISegmentationApp:
// See MRISegmentation.cpp for the implementation of this class
//

class CMRISegmentationApp : public CWinApp
{
public:
CMRISegmentationApp();

 // Overrides
public:
virtual BOOL InitInstance();

 // Implementation

DECLARE_MESSAGE_MAP()
 };

 extern CMRISegmentationApp theApp;

你在某处有一个空指针。在调试->异常中启用中断访问冲突,使其停止在该位置。然后在调用堆栈停止时向上遍历代码。
m_pMainWnd=&dlg请记住,对话框关闭后,
mpmainwnd
将成为垃圾。我在这一行的winmain.cpp中得到了访问冲突。如果(!pThread->InitInstance())如此,则每当我运行时,它都会在此处得到冲突。请沿着调用堆栈查找代码。调用堆栈应该位于工具栏上的组合框中。如果调用堆栈中没有任何代码,则错误可能存在于未显示的代码中。