为什么我会收到此错误? [英] Why I get this error?

查看:89
本文介绍了为什么我会收到此错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调试断言失败 - 导致此错误的原因是什么?



- dll的代码与其他项目相同,但在其他项目中我没有得到此错误,但在一个项目中我收到此错误..



-

debug assertion failed - what are the causes of this error?

- the code for the dll is same as the other projects but in others i don't get this error but in one project iam getting this error..

-

if ( m_wndSplitter.CreateView(nRow, nCol, n_pViewClass, CSize(0, 0), &context) == FALSE )
	{
        TRACE( "Failed to Create View\n" );
		ASSERT(0);
		return NULL;
	}





-在其他项目中的if()语句后,它会转到特定的dll的showwindow()函数。但为什么它不会在这种情况下?



-所有if()中的参数都获得有效值。



我尝试过:





-after this if() statement in other projects it goes to he particular dll's showwindow() function ..but why it is not going in this case?

-all the parameters in the if() are getting valid values .

What I have tried:

// c14OCDlg.cpp : implementation file
//

#include "stdafx.h"
#include "..\main\CommonDlgRes.h"
#include "OutputContactRes.h"
#include "..\CommonDLLEx\CLabel.h"
#include "..\common\OfflinerCommon.h"
#include "c14OCDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// c14OCDlg

#define MAX_LEN	12

IMPLEMENT_DYNCREATE(c14OCDlg, CFormView)

c14OCDlg::c14OCDlg()
	: CFormView(c14OCDlg::IDD)
{
	//{{AFX_DATA_INIT(c14OCDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_bInitialUpdate = FALSE;		
	m_pFrame         = NULL;
}

c14OCDlg::~c14OCDlg()
{
}

void c14OCDlg::DoDataExchange(CDataExchange* pDX)
{
	int MaxChars = MAX_LEN;
	int i = 0;
	
	CStringArray tmpOutputContact;
	tmpOutputContact.SetSize(m_pOutContact->GetSize());
	
	// get a copy for compares!
	if ( pDX->m_bSaveAndValidate == TRUE )
	{
		for (i = 0; i < m_pOutContact->GetSize(); i++ )
			tmpOutputContact[i] = m_pOutContact->GetAt(i);
	}

	try
	{

	CFormView::DoDataExchange(pDX);

	DDX_Control(pDX, IDC_STATIC_DEV_TITLE, m_lblTitle);

	int iIndex = 0;
	DDX_Text(pDX, EDIT_OUT1, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

	iIndex++;
	DDX_Text(pDX, EDIT_OUT2, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

    iIndex++;
	DDX_Text(pDX, EDIT_OUT3, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

    iIndex++;
	DDX_Text(pDX, EDIT_OUT4, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

	iIndex++;
	DDX_Text(pDX, EDIT_OUT5, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

	iIndex++;
	DDX_Text(pDX, EDIT_OUT6, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

	iIndex++;
	DDX_Text(pDX, EDIT_OUT7, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

	iIndex++;
	DDX_Text(pDX, EDIT_OUT8, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

	iIndex++;
    DDX_Text(pDX, EDIT_OUT9, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);
	
	iIndex++;
    DDX_Text(pDX, EDIT_OUT10, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

	iIndex++;
    DDX_Text(pDX, EDIT_OUT11, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

	iIndex++;
    DDX_Text(pDX, EDIT_OUT12, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

	iIndex++;
    DDX_Text(pDX, EDIT_OUT13, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);

	iIndex++;
    DDX_Text(pDX, EDIT_OUT14, (*m_pOutContact)[iIndex]);
	DDV_MaxChars(pDX, (*m_pOutContact)[iIndex], MaxChars);


	}
    catch(...)
	{
		// data failed, so restore old data
		if ( pDX->m_bSaveAndValidate )
			m_pOutContact->Copy(tmpOutputContact);
	}

	if ( pDX->m_bSaveAndValidate )
	{
		bool bChanged = false;
		for (i = 0; i < m_pOutContact->GetSize(); i++ )
		{
			if ( tmpOutputContact[i] != (*m_pOutContact)[i] )
			{
				bChanged = true;
				break;
			}
		}

		if (bChanged)
			GetDocument()->SetModifiedFlag( TRUE );
	}
}


BEGIN_MESSAGE_MAP(c14OCDlg, CFormView)
	//{{AFX_MSG_MAP(c14OCDlg)
	// NOTE - the ClassWizard will add and remove mapping macros here.
	ON_WM_SHOWWINDOW()
	ON_BN_CLICKED(IDC_RETURN, OnReturnKeyPress)	
	ON_WM_CLOSE()	
	ON_WM_TIMER()
	ON_EN_CHANGE(EDIT_OUT1, OnChange)
	ON_EN_CHANGE(EDIT_OUT2, OnChange)
	ON_EN_CHANGE(EDIT_OUT3, OnChange)
	ON_EN_CHANGE(EDIT_OUT4, OnChange)
	ON_EN_CHANGE(EDIT_OUT5, OnChange)
	ON_EN_CHANGE(EDIT_OUT6, OnChange)
	ON_EN_CHANGE(EDIT_OUT7, OnChange)
	ON_EN_CHANGE(EDIT_OUT8, OnChange)
    ON_EN_CHANGE(EDIT_OUT9, OnChange)
	ON_EN_CHANGE(EDIT_OUT10, OnChange)
	ON_EN_CHANGE(EDIT_OUT11, OnChange)
	ON_EN_CHANGE(EDIT_OUT12, OnChange)
	ON_EN_CHANGE(EDIT_OUT13, OnChange)
	ON_EN_CHANGE(EDIT_OUT14, OnChange)
	ON_EN_SETFOCUS(EDIT_OUT1, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT2, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT3, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT4, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT5, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT6, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT7, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT8, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT9, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT10, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT11, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT12, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT13, OnSetfocusOut)
	ON_EN_SETFOCUS(EDIT_OUT14, OnSetfocusOut)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// c14OCDlg diagnostics

#ifdef _DEBUG
void c14OCDlg::AssertValid() const
{
	CFormView::AssertValid();
}

void c14OCDlg::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// c14OCDlg message handlers

void c14OCDlg::GetData()
{

	m_pFrame = GetParentFrame();
	// get data
	LRESULT lResult = 0;
	lResult = m_pFrame->SendMessage(WM_GET_DATA, OUTPUT_CONTACTS);
	m_pOutContact = (CStringArray *)lResult;
}

void c14OCDlg::OnInitialUpdate() 
{
	GetData();
	
	
	CFormView::OnInitialUpdate();
	m_bInitialUpdate = TRUE;

	m_lblTitle.SetText("Output Contact Names");
	m_lblTitle.SetFontBold(TRUE);
	m_lblTitle.SetFontSize(CONST_TITLE_TEXT_SIZE);
}


//------------------------------------------------------------------------
// METH NAME: OnShowWindow(BOOL bShow, UINT nStatus) 
// ACTION   : if we are showing, make the first control active		
// RETURNS  :
// GLOBALS  : 
// COMMENTS : 
//------------------------------------------------------------------------
void c14OCDlg::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CFormView::OnShowWindow(bShow, nStatus);
	
	if ( bShow == TRUE && m_bInitialUpdate == TRUE )
	{
		CWnd *wnd = GetDlgItem( EDIT_OUT1 );
		wnd->SetFocus();
	}	
}


//-----------------------------------------------------------------------------
// FUNCTION NAME : OnReturnKeyPress()
// ACTION		 : pass focus to the next control when the return-key is pressed.
// RETURN		 :
// GLOBAL		 :
// REFERENCE	 :
// COMMENT		 : ask the window to handle the job by means of window messaging.
//-----------------------------------------------------------------------------
void c14OCDlg::OnReturnKeyPress() 
{
	PostMessage( WM_NEXTDLGCTL, 0, 0L);
}


// =============================== EN_CHANGE Message Handler ==========================
void c14OCDlg::OnChange() 
{
	UpdateData(TRUE);
}



void c14OCDlg::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	if ( lHint == SAVING_FLAG_ )
		UpdateData( TRUE );
	else if ( lHint == LOADING_FLAG_)
		UpdateData( FALSE );
	else if ( lHint == UPDATE_FLAG_ )
	{
		GetData();
		UpdateData( FALSE );	
	}
}


void c14OCDlg::OnClose() 
{
	m_bInitialUpdate = FALSE;
	this->EnableWindow( FALSE );
	this->ShowWindow( SW_HIDE );
	
	CFormView::OnClose();
}

void c14OCDlg::OnSetfocusOut() 
{
	if ( m_pFrame )
	{
		sprintf(m_Tip.szLarge, "Enter up to %d characters for Output Contact name.", MAX_LEN);
		m_pFrame->SendMessage(WM_SB_TIP, MSG_STRING, (LPARAM)&m_Tip.szLarge);
	}
}

BOOL c14OCDlg::PreTranslateMessage(MSG* pMsg) 
{
#if 1 //Check for special charector
	HANDLE hCopyData;
	char *szText;
	CString szSpecial;

	if( pMsg->wParam == 'V' ) //Check for Paste
	{
		if( IsCTRLpressed() )
		{
			if( OpenClipboard() )
			{
				hCopyData = GetClipboardData(CF_TEXT);
				CloseClipboard();
				szText = (char*)GlobalLock(hCopyData);
				szSpecial = szText ;
				for (int n = 0; n < szSpecial.GetLength(); n++)
				{
					UINT uiKey = unsigned int(szSpecial[n]);

					if (!isdigit(szSpecial[n]) && CheckForSpecialChar(uiKey) )
						return TRUE;					
				}			

			}
		}
	}
	if ( pMsg->message == WM_CHAR )
	{
		return CheckForSpecialChar((unsigned int ( pMsg->wParam )));
	}	
#endif

	return CFormView::PreTranslateMessage(pMsg);
}

推荐答案

要找到答案,您需要仔细查看传递给函数的所有参数 - 并且意味着当你检查它们时你的代码需要运行。我们无法做到这一点,因为我们无法在相同的条件下运行您的代码 - 我们没有代码片段或您使用的任何数据的任何上下文。



所以,这取决于你。

幸运的是,你有一个工具可以帮助你找到正在发生的事情:调试器。你如何使用它取决于你的编译器系统,但是一个快速的谷歌用于你的IDE名称和调试器应该给你你需要的信息。



放一个断点在函数的第一行,并通过调试器运行代码。然后查看您的代码,并查看您的数据并找出手动应该发生的事情。然后单步执行每一行检查您预期发生的情况正是如此。如果不是,那就是当你遇到问题时,你可以回溯(或者再次运行并仔细观察)以找出原因。


对不起,但我们不能为你做到这一点 - 时间让你学习一门新的(非常非常有用的)技能:调试!
To find out, you need to look very closely at all the parameters you are passing to the function - and than means your code needs to be running when you check them. We can;t do that, as we can't run your code under the same conditions you do - we don't have any context for the code fragment, or any of the data you use.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on your compiler system, but a quick Google for the name of your IDE and "debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!


这篇关于为什么我会收到此错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆