variables using ClassView and Class wizard

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: seia0106 (miahmed67_at_yahoo.com)
Date: 04/03/04


Date: 3 Apr 2004 11:04:28 -0800


"Scott McPhillips [MVP]" <scottmcp@mvps.org.nothere> wrote in message news:<uLZOE#xFEHA.3456@tk2msftngp13.phx.gbl>...
> seia0106 wrote:
>
> > Hello everyone.
> > In a MFC program I want to define two variables one of template type
> > MytemplateClass<int> X;
> > and to assign another variable to a ActiveX control(Wang Control of
> > windows).
> > CImgEdit m_bImage1;
> >
> > I tried to define first variable(template type) using 'Class View'
> > and second variable(control type) using 'Class Wizard'. But in both
> > cases i got the error.
> >
> > "Unhandled exception in myprogram.exe (NTDLL.DLL) 0xc0000005:Access
> > Violation"
> >
> > I looked into some books and papers but could not find out what is
> > causing this error here and how it can be fixed.
> > Would someone please tell me what is it that i am doing wrong here and
> > how it can be corrected.
> > Thanks.
>
> Both class view and class wizard are simply typing aids. The way the
> code compiles and executes has nothing to do with how the code was
> created.
>
> The error can not be diagnosed without seeing the lines of code that
> caused it. An access violation means your code has a bug, probably from
> incorrect use of pointers or array indexes. Make sure you are building
> the debug configuration of your program, then run it in the debugger.
> You need to find out what point in your code causes the problem. If the
> access violation occurs while debugging then the debugger's stack window
> is especially useful in showing you how your code led to this error.

Thank you Scott for your reply.

I only have the 'release version' of the program that i am trying to
improve. Iniitally the breakpoints could not be set. After changing
project settings in C++ tab to 'program database' and in Linker tab to
generate debug info the release version can be debugged now.
But my problem persists. That is when i define a new variable in my
main class(mytemplateclass<int> X or when i assign variables(of any
type) to a control(any control) on my MFC GUI, then program runs fine
and gives correct results but when program exits then above 'access
violation error' occurs. I wonder if this has something to do with
Debug/Release. And if it is so how can
I solve it or what changes i have to made to prject settings or what i
have to do for making changes to this program, which i only have in
release mode?
I am quite new to MFC programming and this problem is puzzling for me.
Can someone please give some hint what could be causing this error and
how to fix it? thanks.



Relevant Pages

  • Re: variables using ClassView and Class wizard
    ... > In a MFC program I want to define two variables one of template type ... Both class view and class wizard are simply typing aids. ... An access violation means your code has a bug, ... the debug configuration of your program, then run it in the debugger. ...
    (microsoft.public.vc.language)
  • Program works when running from debugger but not as an .EXE
    ... Hi have a MFC program that reads voltage measurements from a mulitmeter ... via GPIB using VISA API. ... debugger but crash with the following error when running from the ... got the following error signature: ...
    (microsoft.public.vc.debugger)
  • memory leaks
    ... i have a large MFC program with multi-threading. ... i'm getting some memory leaks from the debugger. ...
    (microsoft.public.vc.language)