Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Project xxx.exe raised exception calss EAccessViolation

Status
Not open for further replies.

xljohn

Programmer
May 20, 2003
13
BR
Greetings,

I have built a BCB6 project and it passed compiling process. When I run it, the run time error occurs:

Project srdss.exe raised exception class EAccessViolation with message 'Access violation at address 00542A61. Read of address 00000000'. Process stopped.

I tried to put this to the main form file srdss.cpp in FormCreate and FromActivate:

ShowMessage("application started!\n");

but even this can not show up. So the program did not start at all. The error arises since the initialization process.

Please give some idea to conquer this problem. Thanks very much.

John
 
When BCB programs start, it usually starts in this order:
1. OnCreate
2. OnShow
3. OnActivate
4. OnPaint

One thing I notice is this warning:
Note: Use of the OnCreate event is discouraged in C++Builder because it can interact badly with the form’s constructor (see OldCreateOrder). It is recommended that you override the form constructor instead.

Do you have anything in any of these events besides the ShowMessage? Are you defining/initializing a class of your own?


James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
James,

Thanks for your message.

I tried to do something to crack this problem.

Firstly, I delete all the printers, useless.

Secondly, I tried it on another machine, Windows XP and with MapObject 2.1 installed, useless. But the difference is that an error report was created. But it does not help.

Thirdly, I cut and paste the code in OnCreate to the constructor, as shown below:

__fastcall TFormMain::TFormMain(TComponent* Owner)
: TForm(Owner)
{

ShowMessage ( "program starts here!\n");
ready=false;
Application->OnIdle = MyIdleHandler;
}

this also does not work.

Actually, I even put the ShowMessage in the main program as shown below:

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{

ShowMessage( "start the application!\n");

try
{
Application->Initialize();
...

The message does not show at all. So maybe the program did not start at all. What happened?

Thanks for your suggestions. Thank you very much. Though things are still bad now.

Thanks.
John


 
James,

After I read your suggestions in another thread, I checked my project settings and find it's already an stand-alone project.

I read the FAQs you posted, and tried to find the DLL files.

Below is the result of the utility call:

C:\Karl\pc_iie_jan_18\srdss>tdump -em. srdss.exe
Turbo Dump Version 5.0.16.12 Copyright (c) 1988, 2000 Inprise Corporation
Display of File SRDSS.EXE

IMPORT: ADVAPI32.DLL
IMPORT: KERNEL32.DLL
IMPORT: VERSION.DLL
IMPORT: WSOCK32.DLL
IMPORT: WINSPOOL.DRV
IMPORT: COMCTL32.DLL
IMPORT: COMDLG32.DLL
IMPORT: GDI32.DLL
IMPORT: SHELL32.DLL
IMPORT: USER32.DLL
IMPORT: OLE32.DLL
IMPORT: OLEAUT32.DLL

I think this may be helpful for you to make a judgement.

Thanks for your help.
John
 
Do you have any timers that are running in your program? Read of address 0 means that you are trying to access a NULL pointer. Somewhere you are accessing an object that hasn't been created yet is my guess. It is best not to use a messagebox in this case to locate the problem. You need to use breakpoints. I would breakpoint at the OnCreate event and step through until you see the error come up.

Chris
 
Chris,
Thanks for your thread. Though it does not help.
The problem is that the program even can not step into the WinMain(). So all break points are useless.

Every time the screen will go to the ios_base() in the following:


template <class _CharT, class _Traits>
basic_ios<_CharT, _Traits>::basic_ios()
: ios_base(),
_M_fill(_STLP_NULL_CHAR_INIT(_CharT)), _M_streambuf(0), _M_tied_ostream(0)

{}

I think if it's the program's problem, then at least it should stop at the breakpoint or it should show the message box.

So now I'm totally lost. It's beyond my ability. My boss should hire an expert.

Anyway, thank you for your message.
John
 
That is very odd... This is going to be an obvious statement, but it's gotten me many times, so I'll go ahead and say it meaning no offense to you. Did you set the compile options to Full Debug and make sure that the breakpoints are enabled that way? You might try also compiling with Release compile options.

Try starting the program by stepping into it, then step through without the CPU window open and see if it leads you to your problem.

If not, try changing program options to build with runtime packages or not build with runtime packages.

Also be sure your executable file size is less than 2.9 megs after compiling.

I know these are probably obvious, but I don't know enough about the software to suggest anything else, sorry!

Chris
 
The usual delete all objs. and tds files

I use the foloing in the project directory to clean up the directory. it comes in handy when I am doing a backup or when I need to remove all temporary files.

(clean.bat)
@echo
del *.ilf
del *.ils
del *.ilc
del *.ild
del *.obj
del *.tds
del *.~*
del *.exe
pause

if the project is not to big start over with a blank form and go slowly from there. sometimes I have to start over in this manner when some inexplicable error pops up that i am sure has no fault that I can find. I have found it useful to open the unit.cpp file in a text editor before I do any work on the code. This way if some error pops up and I have lost track during the session I have the code at the beginning of the session loaded for easy access. I also make frequent backups of the project during the developement. at least once a week or when I have made a significant change. That way I dont always have to start over from scratch. I just go back to the last workable backup.

there are three things to learn to do when you write code.

1. make frequent backups
2. make a copy of the above bakups
3. make copies of the first two backups.

builder can sometimes be finicky. :)

tomcruz.net

 
After reading the following thread I realize my post may not be appropriate for you. If this is the project you mentioned earlier with 1hundred or more files would think you got your hands full.. you might try looking at the network code first.

good luck

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top