Re: Debug Assertion Failed

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



Actually, it says in the comments "Did you remember to call DoPreparePrinting". I would
suspect this is a dead giveaway as to what is wrong!

Trust The Source, Luke!

(And that means learn what that [Retry] button means, which is carefully explained in the
message...)
joe

On Wed, 20 Dec 2006 05:44:55 -0500, David Wilkinson <no-reply@xxxxxxxxxxxx> wrote:

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
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Debug Assertion Failed
    ... when i create a new second form and add in FileOnPrint and FileOnPrintPreview command from the MFC classwizard. ... When you get an assertion error, make sure you are running under the debugger and look at what the assertion says. ... If you look at the call stack between your code and where the assertion happens then you may see what has gone wrong. ...
    (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)