on 09-16-2014 6:32 PM
When the Restart() function executes, the program fatal crashes with "Sybase Powerbuilder 12.5 has stopped working"
I set a breakpoint at the function, but when I try to step into it, it crashes.
Restart documentation: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc37781.1250/html/psref/BFC...
Any help or suggestions?
PowerBuilder Classic Version 12.5.2 Build 5583
Hi Stephen;
Note1: Restart ( ) should only be used when running your PB application from an EXE.
Note2: Running from the PB IDE will make your PB application a sub-task of the IDE. Thus, a Restart ( ) will crash PB.
Note3: If you issue a Restart on a failed DBMS connection, it will attempt to perform a Commit & Disconnect. So make sure your application ignores errors in this area if a restart is in progress.
HTH
Regards ...Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have deployed the application and am running the .exe file, but when it hits the Restart() function it still does a fatal crash - "abc.exe has stopped working"
A. I tried putting a try/catch around the Restart() function and a messagebox for its return value, but it never returns from the Restart() nor does it throw an exception.
B. I also tried running the .exe as administrator.
C. I also tried putting the Restart() into its own function.
What OS version? What database are you connected to?
Windows 8.1 Pro
Sql Server 2005
PowerBuilder Classic Version 12.5.2 Build 5583
What is the app doing before the Restart? What event calls it?
Before it is called, a physical network disconnect occurs and it enters the DBError event of the parent transaction object. It than loops through disconnect, connect, sleeping 10 seconds, and then testing the database connection until the database connection works. After that, a Restart() is called.
** Manually disconnect network connection **
dw_abc.Retrieve()
** General Network Error messagebox pops up **
uo_transaction - DBError()
{
if code = 11 then
messagebox("Reconnecting to database...", "")
do
this.test_sql() // function that runs simple SQL to test database connection
if this.SQLCode < 0 then
sleep(10)
DISCONNECT using this;
CONNECT using this;
end if
loop while this.SQLCode < 0
messagebox("Connected! - Restarting abc...", "")
Restart()
end if
return code
}
** I get the last message box and after clicking it the application fatally crashes at Restart() - "abc.exe has stopped working"**
I just checked the help for Restart and it says:
Stops the execution of all scripts, closes all windows (without executing the scripts for the Close events), commits and disconnects from the database, restarts the application, and executes the application-level script for the Open event.
So it does not run the close events. I do however agree with your suggestions. I would put the Sleep after the Disconnect as well.
Thanks for the update Roland!
I would suggest that Ted go one step further though and remove all DML that he is using in the DBError event (and skip your Sleep suggestion)!
Instead, just issue the message, then run a DBCancel ( ), post a UE* and then exit the script immediately by issuing a RETURN 3 command.
* - Put the restart ( ) in the User Event.
Regards ... Chris
Hey guys, thanks for all of your input, after talking with my boss, we went a different route (with code already existing on another project).
Using an external function placed in "Global External Functions"
FUNCTION ulong GetCurrentDirectoryA(ulong BufferLen, ref string currentdir) LIBRARY "Kernel32.dll"
I am able to get the current directory of the running exe and then using WScript.Shell, I am able to do my own restart. With the added benefit that I can auto login the user back into the system.
string ls_curdir
ulong l_buf
l_buf = 2048
ls_curdir = space(l_buf)
GetCurrentDirectoryA(l_buf, ls_curdir) // return double byte
string ls_full_path
ls_full_path = ls_curdir + "\" + string(abc.AppName) + ".exe" + " " + gs_username + ", " + gs_password
CONSTANT integer NORMAL = 1
CONSTANT boolean WAIT = FALSE
integer li_rc = 0
OleObject wsh
wsh = CREATE OleObject
li_rc = wsh.ConnectToNewObject( "WScript.Shell" )
li_rc = wsh.Run(ls_full_path, NORMAL, WAIT)
HALT CLOSE
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stephen;
FYI ....
1) GetCurrentDirectoryA should be GetCurrentDirectoryW
2) You really should use the API - GetModuleFileNameW
- the current directory may not be where the EXE actually came from!
=> http://msdn.microsoft.com/en-ca/library/windows/desktop/ms683197%28v=vs.85%29.aspx
Good luck!
Regards ... Chris
Hi Stephen,
How exactly did you code this. I did a simple test along the lines of the documentation.
I put idle(100) in the open event of the application and Restart() in the idle event of the application and it is working just fine.
I tested with 12.5 2511 and 12.5.2 5006.
Ted Zimmerman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.