First-chance exception in test.exe (KERNEL32.DLL): 0xC0000005: Access Violation.

It doesn't matter if I create a new MFC App as MDI, SDI or Dialog-Based. Whenever I start my program in debug, I get a gazillion of these exceptions and I can't figure out why. I've traced (at least the first set of these, there seem to be a set for the main window, the toolbar, and possibly the status bar) it down to a call to CWnd::::CreateWindowEx(...). This is a function I cannot step into and causes a ton of these exceptions to be spit out at me. All I've done is create the application (either MDI, SDI or Dialog-based) using the AppWizard, compiled and run it. Nothing fancy, and nothing to explain what is happening. Any ideas? I'd be happy to list out the options I chose in AppWizard. I'm running Visual C++ 6.0.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

'First-chance exception in kernel32.dll...' just means that a function from within the 'kernel32.dll' caused an access-violation exception that was handled successfully inside the SEH frame that was active when the exception occurred. You can think of it being the same as if you use code like this:

long l;

__try // set up current SEH frame
CopyMemory ( &l, 0, sizeof ( long)); // read from 0x00000000
__except( EXCEPTION_EXECUTE_HANDLER) // handler for current frame
puts ( "We knew that this would go wrong...");

(Additional info: MS KB Article Q105675)

The article can be found at 

A first chance exception is called so as it is passed to a debugger before the application 'sees' it. This is done by sending a 'EXCEPTION_DEBUG_EVENT' to the debugger, which can now decide whether it is passed to the apllication to handle it or 'ignore' it (e.g. like an 'EXCEPTION_BREAKPOINT' aka 'int 3')

If the exception isn't handled, it becomes a '2nd chance' exception, the debugger 'sees' it the 2nd time and will usually terminate the program (without using a debugger, these exceptions end up at 'UnhandledExceptionFilter()' which will also signal the exception to the user with one of these 'nice' message boxes and terminate the program, also...)

BTW: 'first chance' exceptions are only displayed when running a debugger - you can safely ignore them...
Feel free to ask if you need more infromation!
superstarrAuthor Commented:
Well, thing is, I can run the same test on another computer with a similar configuration and not get the problem. This isn't normal behavior and I don't want to ignore the problem because it takes about 1-3 minutes for the debugger to finally be running without spitting out all of those exception error messages. I understand what the exception is, I just don't know what's causing it to occur more times than I can count and how to get rid of it.
Vinayak KumbarSr Program ManagerCommented:

Which version of vc u r using. do u have the latest service pack for vc in Ur machine?. I think, u install vc++ once again along with the service pack and y2k patch. That will solve Ur problem

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

You've probably just got your debugger set up incorrectly.  (which would explain why when you do it on another machine your problems disappear).

Go into the VC++ exceptions dialog (Debug\Exceptions) and press on the "reset" button.  This will stop the debugger from trapping all exceptions unless they are handled somewhere.  Unhandled exceptions are the ones you really have to worry about.

As for jkr - access violations are not the only exceptions!!
>>Well, thing is, I can run the same
>>test on another computer with a
>>similar configuration and not get the

Well, I assume it's a different OS version - there's hardly anything you can do about these exceptions...
Janusz CzopowikCommented:
Zip your code and e-mail it to me.
superstarrAuthor Commented:
Done JohnCz... decent insight will win you the points. :)

jkr - same OS version for both CPUs : Winnt 4.0 (Workstation) Service Pack 4. One major difference between the one that works and the one that doesn't is that when I installed IE that comes with Visual C++ 6.0, I did not enable the explorer extension for active desktop on the one that doesn't work - could that be a problem?

VinExpert - I will probably resort to reinstalling everything when I finish working on my current project on this computer (which does not involve Visual C++) as I don't want to muck up the system that does the job I need to do right now. :)

Thanks for all the comments thus far!
Janusz CzopowikCommented:
In my almost always humble opinion, your problem is not within operating system. Neither IE nor Service pack has anything to do with your problem. It seems like you have .lib and corresponding .dll files out of synch. Did you

I think you should not have removed previous version of the Visual C++ (Visual studio) before upgrading. Removal of the old versions of the programs does not always guarantee removal of the DLL files, and I don’t recall now but some of other shared files may have been left on your drive.

Some “extreme” measures:
Remove a version you are currently using, make sure that directory you keep your VC++ files is wiped off. I would also go a little further and check for existence of any MSV*.* and MFC*.* files and remove all I could.

Removing or renaming HKEY_CURRENT_USER\Software\Microsoft\DevStudio and/or HKEY_LOCAL_MACHINE\Software\Microsoft\DevStudio if left, would not harm but help.

After that, try to reinstall your newest version and service packs. It seems like a little work but is better than reinstalling OS.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
superstarrAuthor Commented:
Decent insight - from all of you. I will reinstall everything once I'm done with another project I'm working on not using Visual C++ in a few weeks and hopefully it will work then. Thanks for the help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.