• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

Sudden Exception Raises!

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
mirghani
Asked:
mirghani
  • 19
  • 6
  • 3
1 Solution
 
Alisher_NCommented:
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
 
mirghaniAuthor Commented:
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
 
mirghaniAuthor Commented:
i'am not using threads in my APP or what do u mean,actually i can't understand u!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
mirghaniAuthor Commented:
Adjusted points to 100
0
 
Alisher_NCommented:
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
 
mirghaniAuthor Commented:
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
 
mirghaniAuthor Commented:
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
 
mirghaniAuthor Commented:
listening
0
 
Alisher_NCommented:
hmmm... stupid question, did you create that with TCustomWebDispatcher.Create ?;
0
 
mirghaniAuthor Commented:
hi Alisher N,
No.
0
 
mirghaniAuthor Commented:
hi Alisher N,
No.
0
 
geobulCommented:
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
 
mirghaniAuthor Commented:
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
 
mirghaniAuthor Commented:
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
 
geobulCommented:
Hi,

My email:
geobul@usa.net

Send it! I'll try to help.

Let me know what is your http server.

Regards, Geo

0
 
mirghaniAuthor Commented:
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
 
geobulCommented:
Hi Meer,

I've received an empty attachement :-(

Send it again please !!!

Regards, Geo
0
 
mirghaniAuthor Commented:
hi geo,
check it again now and reply as fast as possible,
i'am waiting
Regards Meer.
0
 
mirghaniAuthor Commented:
hi geo,
check it again now and reply as fast as possible,
i'am waiting
Regards Meer.
0
 
mirghaniAuthor Commented:
Hi Geo,
Did u Recieve???
0
 
mirghaniAuthor Commented:
Hi Geo,
 Did u recieve the attachement,
or should i send it again???
0
 
geobulCommented:
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
 
geobulCommented:
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
 
mirghaniAuthor Commented:
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
 
mirghaniAuthor Commented:
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
 
geobulCommented:
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
 
mirghaniAuthor Commented:
Thanks Geo,
i will depend on Build All all the Time:-)
Regards
Meer
0
 
mirghaniAuthor Commented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 19
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now