Re: Debug Assertion Failed

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Newbie & Noobie wrote:

Hi, when i create a new second form and add in FileOnPrint and FileOnPrintPreview command from the MFC classwizard. On the Constructor, i added the following code:

void CProduct::OnFilePrint() {
// TODO: Add your command handler code here
CFormView::OnFilePrint() ; // code added
}

when execute and press the print button to test whether it is working or not, I got the following error:

Debug Assertion Failed.
File: viewprnt.ccp
Line: 161

How do I remedy the problem.
Thanks.


Noob:

When you get an assertion error, make sure you are running under the debugger and look at what the assertion says. Then follow up the call stack until you get to your code, and think what you could have done to cause it.

In this case, the problem is that the printer device context is NULL, which suggests there is something wrong about how you have hooked up this view. If you look at the call stack between your code and where the assertion happens then you may see what has gone wrong.

David Wilkinson
.



Relevant Pages

  • Re: Debug Assertion Failed
    ... Add your command handler code here ... When you get an assertion error, make sure you are running under the ... If you look at the call stack between your code and where the ...
    (microsoft.public.vc.mfc)
  • Re: VS_VERSION_INFO static ctrl
    ... I was calling to make the static control change before I have a window. ... Yes I called SetWindowText() in the CAboutDlg::OnInitDialog. ... I'm getting the Assertion Error. ...
    (microsoft.public.vc.mfc)
  • Re: CAS,Stackwalk and code reuse
    ... You will need to make the assertion inline in your method in order for it to ... Statemen ts to elevate CAS ... how it CAS work .It's evaluated for a stack walk and not for a thread.. ... 3)Code snipet now in VS 2005..but I am not sure if snipet work in ...
    (microsoft.public.dotnet.security)
  • Re: Interesting NLHE hand in SnG this morning
    ... Interesting assertion, and one which I disagree with profoundly. ... I play the same Party games as you. ... chip stack on proportion to the blinds, ... and AA again to wipe out the third place player. ...
    (rec.gambling.poker)
  • Re: Assertion error with popup dialog
    ... PreTranslateMessage function causes it to fail, but if I called it from the ... OnInitialUpdate function the dialogs work fine. ... I don't get the assertion error if I do not call the dialogs. ...
    (microsoft.public.vc.mfc.docview)