Solved

Sudden Exception Raises!

Posted on 2000-02-25
28
380 Views
Last Modified: 2012-08-14
My App uses Standalone CGI it was ok till i started recieving Windows Message:("your program has performed illegal operation..."with buttons close,Debug and Details).
when choosing the button close directly i recieve an E:EFCreateError cann't create module FileName.exe.
attention:when i delete this file from the given path and reexecute it from Delphi(i mean new creation for exe)it works well but for once and i have to repeat the same thing again and again.
this Exception Appears as i think when i add cookies to my App,if u think cookies is the Pb let me write the code i implement to check it.
thanks
0
Comment
Question by:mirghani
  • 19
  • 6
  • 3
28 Comments
 
LVL 3

Expert Comment

by:Alisher_N
ID: 2560621
this means some thread is locking your.exe and hanging... does it start after reboot ?... it is something wrong with a code, hard to say more detaily w/o source

0
 

Author Comment

by:mirghani
ID: 2560720
hi Alisher N,
i said when i delete my .exe and recompile it to generate another one it works but for once:-(
what do u mean by starting After Reboot?
0
 

Author Comment

by:mirghani
ID: 2560725
i'am not using threads in my APP or what do u mean,actually i can't understand u!
0
 

Author Comment

by:mirghani
ID: 2560851
Adjusted points to 100
0
 
LVL 3

Expert Comment

by:Alisher_N
ID: 2560880
you shuld check whole your program... this error appears when something in your code hangs a system (sync. read from com port for example will wait and not return untill something received from that port etc etc). That's why .exe will be blocked for access. This is general situation and it is not possible to find a reason without checking WHOLE sources...

tell us more details what actions performed in your application, what is CGI part doing, how they interact, do you have open sockets, connections ? does it hangs while in CGI program or inside your code ?

too many possibilities for that...

0
 

Author Comment

by:mirghani
ID: 2560899
My App Control a Discussion Group(Registration form,AskQues,...etc)as Experts Exchange Side.
i tried to add cookies to my app what i did is as follows:
After validation of the login and password:

var
passw,login:string;

begin

login:=Request.contentfields.values['login'];
Response.cookies.Add;
Response.cookies.items[0].name:='login';
Response.cookies.item[0].value:=login;

Response.cookies.Add;
Response.cookies.items[1].name:='passw';
Response.cookies.item[1].value:=passw;

end;
this what i did as addition in my code and i started recieving this Exception.
i hope u got it:-)
0
 

Author Comment

by:mirghani
ID: 2560904
it hangs from the browser if i write an html code for example if give form action="filename.exe",not from delphi,in delphi while compilation there is no errors.
why do u think that it is ok for once only????
0
 

Author Comment

by:mirghani
ID: 2561028
listening
0
 
LVL 3

Expert Comment

by:Alisher_N
ID: 2561244
hmmm... stupid question, did you create that with TCustomWebDispatcher.Create ?;
0
 

Author Comment

by:mirghani
ID: 2562115
hi Alisher N,
No.
0
 

Author Comment

by:mirghani
ID: 2562117
hi Alisher N,
No.
0
 
LVL 17

Expert Comment

by:geobul
ID: 2564465
Hi,

  I strongly recommend you to use SetCookieField method when setting cookies in Response object!
  I think that I've already posted the code to you.

Regards, Geo
0
 

Author Comment

by:mirghani
ID: 2564795
hi Geo,
do u think the Exception Raise because of this reason And do u think if i use ur method i Will not recieve any Exception,if ur Answer yes let me Check this code.
more details needed about this Exception?
Regards Meer.
0
 

Author Comment

by:mirghani
ID: 2568230
hi Geo,
i tried ur previous method of setting cookies using TStringList:

Response.SetCookieField(....);

and it is not working(i mean cookies never set),i tested this by :

Response.content:=Request.cookiefields.
text;

and it works with the other method:

Response.Cookie.add
Name:='sname';
value:='svalue';
....;
....;
but the pb with this method that i need to Refresh the browser when login so the cookies would be set,the same thing when logout(clicking Refresh to be filled with '' value or zero).
why do u think setcookiefield is not working???
what about the Exception Raises still i recieve this Exception.
let's make a deal, if u solve both pb(Exception Raise+Cookies Setting)u will get the both Question points(250pt).
comment:if u agree i can send the code by Emailing u if needed.
thanks.
Regards Meer.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 17

Expert Comment

by:geobul
ID: 2568584
Hi,

My email:
geobul@usa.net

Send it! I'll try to help.

Let me know what is your http server.

Regards, Geo

0
 

Author Comment

by:mirghani
ID: 2568825
hi geo,
i'am using PWS locally.
in the same machine(127.0.0.1);
forward  i will use it in proxy.
and i will send the code to u:-)
Regards Meer
0
 
LVL 17

Expert Comment

by:geobul
ID: 2572164
Hi Meer,

I've received an empty attachement :-(

Send it again please !!!

Regards, Geo
0
 

Author Comment

by:mirghani
ID: 2572559
hi geo,
check it again now and reply as fast as possible,
i'am waiting
Regards Meer.
0
 

Author Comment

by:mirghani
ID: 2572579
hi geo,
check it again now and reply as fast as possible,
i'am waiting
Regards Meer.
0
 

Author Comment

by:mirghani
ID: 2572997
Hi Geo,
Did u Recieve???
0
 

Author Comment

by:mirghani
ID: 2575493
Hi Geo,
 Did u recieve the attachement,
or should i send it again???
0
 
LVL 17

Expert Comment

by:geobul
ID: 2576042
Hi Meer,

Results:

1. I've added two htm pages

1.1. login1.htm with
  <FORM METHOD=POST ACTION="reg1.exe"> and
  <INPUT TYPE=hidden NAME="sendertag" VALUE="Login">
1.2. main.htm with
  <FORM METHOD=POST ACTION="reg1.exe"> and
  <INPUT TYPE=hidden NAME="sendertag" VALUE="ask">

I'm loading login1.htm directly to the browser. After pressing the button Login i'm receiving main.htm.

In main.htm after pressing submit button I can ask a question.

Problems I've solved:

1. Directory structure
  I've defined three module variables
  MyURL,TablesDir,HTMLDir : string;
  and created WebModule OnCreate event handler:

procedure TWebModule1.WebModule1Create(Sender: TObject);
begin
  MyURL     := 'http://127.0.0.1/reg1.exe';
  TablesDir := 'c:\test';
  HTMLDir   := 'c:\test\';
end;

And everywhere in the code I've replaced 'reg1.exe' with MyURL and
  TableN.DatabaseName := TablesDir;

2. Response.SendRedirect does not work !!!

I've added PageProducer in WebModule under 'ppFile' name and replaced SendRedirect with

  ppFile.HTMLFile := HTMLDir + 'main.htm';
  Response.Content := ppFile.Content;
  Response.SendResponse;

3. I've created WebModule BeforeDispatch event handler, which sends login page if cookies are not set.
This is for security reasons

procedure TWebModule1.WebModule1BeforeDispatch(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
  if Request.ContentFields.Values['sendertag'] <> 'Login' then begin
    if not ReadCookie(Request) then begin
      ppFile.HTMLFile := HTMLDir + 'login1.htm';
      Response.Content := ppFile.Content;
      Response.SendResponse;
    end;
  end;
  { The next line forces the browser to read all pages from the server
    not from the local cache - this is about setting cookies at logout }
  Response.Expires := Now - 1;
end;

That's all and it's working !!!

Regards, Geo
0
 
LVL 17

Accepted Solution

by:
geobul earned 100 total points
ID: 2576123
One more thing for testing purposes:

On logout I send main.htm page as a response again and when the user clicks ASK button, the script returns login page instead of ask page, which means that cookies are empty.

......
(*** Logout ***)
  if Request.Query = 'logout' then
  begin
    Response.Cookies.Add;
    Response.Cookies.Items[0].Name:= 'login';
    Response.Cookies.Items[0].Value:= '';
    ppFile.HTMLFile := HTMLDir + 'main.html';
    Response.content:= ppFile.Content;
    Response.SendResponse;
//    Response.SendRedirect('main.htm');
    Exit;
  end; // if Request.Query
......

And one more ...
In Table1 there is a field 'Id' which corresponds to field 'UserId' in Table2. As I don't know the types of these fields, I've ignored them in my tests.

Regards, Geo
0
 

Author Comment

by:mirghani
ID: 2582880
Hi Geo,
just now i checked ur code,give me a chance to chk it and i will reply to u,
did u find a reason to cause an EFCreateErro(Exception).
thanks.
Regards Meer.
0
 

Author Comment

by:mirghani
ID: 2586582
Hi Geo,
Thanks my new Delphian Friend.
but still the Exception Raises(EFCreateError),and when i choose from Delphi Editor This choice:Project/Build reg1,the program show me Build All Message after that i compile my exe file then no Exception Raises!!!!!!!!
What do u think Geo should i build all the time or there is a solution?????
Regards Meer.a.a
0
 
LVL 17

Expert Comment

by:geobul
ID: 2586724
Hi Meer,

  There was no such error!
  I've always used this way: build all, which makes an exe. My http server needs that exe file. Otherwise I receive '501 Not Supported' from the server.
  What is the other way you are talking about?

  Can you tell me on what page and user's action the exeption is raised?

Regards, Geo
0
 

Author Comment

by:mirghani
ID: 2587321
Thanks Geo,
i will depend on Build All all the Time:-)
Regards
Meer
0
 

Author Comment

by:mirghani
ID: 2587339
About ur Question in Which Action i Reacieve This Exception ,i can tell u that in all the page that its button execute my Reg1.exe
Meer
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now