Web Connection Version Updates and Compilation
February 20, 2009 •
A lot of people seem to have run into problems with the update of Web Connection 5.41. The problem is that you may be running the new version of Web Connection and get an error like the following:
Function FileTime() not found
As it turns out FileTime() is indeed a new function in wwUtils.prg in version 5.41 and it is prominently used in the Process class’s RouteRequest() method and because it’s in RouteRequest, if there is a problem with finding this new function you’ll see an error on every hit agains the Web Connection server.
If you’re seeing this error, the problem is – compilation. I’ve seen several messages and a few support calls about this and IN EVERY INSTANCE the issue was resolved by properly recompiling your code.
Let me explain <g>. When you update a Web Connection installation with the latest version it’s absolutely critical that you recompile all of the PRG and VCX files. Why? Because if you just copy in the new PRG files that are distributed with a new update you are updating only the PRG files and not the FXP files that already exist on your machine! Simply put your FXP files may be newer than the PRG files we ship and so the FXP files are not updated to reflect the latest version of the new program files.
There are two ways to update this right:
- Recompile all files
- Compile the application into an EXE and run the EXE
- Make sure CONSOLE.EXE is up to date
Recompile all Files
Personally I rarely run compiled applications so the first option is what I usually work with. In order to do this I recommend you delete all the FXP files in your Web Connection folder and then either manually recompile or just run the application which should then recreate the FXP files when you run.
The following should do the trick from the command window:
CLOSE ALL
CLEAR ALL
DELETE FILE classes\*.fxp
COMPILE classes\*.prg
COMPILE CLASS CLASSES\*.vcx
NOTE: You cannot use the Project Manager and recompile an APP or EXE file to get the FXP files to update. The project manager can build an up to date EXE/APP, but it will not update FXP files on disk. So an explicit compile is required for the PRG files. VCX files are compiled by the project manager since they are self contained and embedded into the EXE
If for some reason this doesn’t do the trick for you, search for any of the Web Connection FXP files in your FoxPro path in different locations.
To help with this process, the next update to Web Connection there will include be a small helper program that you can use to update your application(s) easily. It’s basically a small PRG file that recompiles all the Web Connection files in your application and also copies all Web related dependency files – scripts, styles, Web Controls, updated DLLs – into one Web directory. You can run this script multiple times to update several Web directories with the latest Web related resources .
In the next rev (5.43 or later) you will be able to do:
DO console\UpdateVersion WITH "c:\inetpub\wwwroot\wconnect"
To force an update of the installation in the install folder and the specified Web folder.
Here’s what this script looks like if you’re interested and don’t want to wait for it in the next update:
************************************************************************
* UpdateVersion
****************************************
*** Function: Updates a Web Connection installation rrrby recompiling
*** all Web Connection files in the classes directory and
*** copying Web support files into a Web directory specified.
*** Assume: Web Path must exist
*** Pass: lcWebPath - Optional, File path to a Web Connection Web
*** you need to run this on each Web site to update
************************************************************************
LPARAMETERS lcWebPath
DO wwUtils
IF EMPTY(lcWebPath)
lcWebPath = GETDIR("\","Please find the Web Directory where files are to be copied","Find Web Directory",64+ 16)
IF EMPTY(lcWebPath)
RETURN
ENDIF
ENDIF
*** Must run out of the Web Connection Root directory!
IF !ISDIR("templates")
WAIT WINDOW "This script needs to be run out of the Web Connection Install Folder"
RETURN
ENDIF
IF !ISDIR(lcWebPath)
WAIT WINDOW NOWAIT "Invalid Web Path specified."
RETURN
ENDIF
lcWebPath = ADDBS(lcWebPath)
LOCAL lcWebTemplate
lcWebTemplate = "templates\webTemplate\"
SET PROCEDURE TO
SET CLASSLIB TO
WAIT WINDOW NOWAIT "Compiling files..."
DELETE FILE classes\*.fxp
COMPILE classes\*.prg
COMPILE CLASS CLASSES\*.vcx
DO wwUtils
WAIT WINDOW NOWAIT "Copying files..."
*** wwScriptLibrary is copied from an embedded resource
CopyTree(lcWebTemplate + "scripts\*.*",lcWebPath + "scripts")
CopyTree(lcWebTemplate + "images\*.*",lcWebPath + "images")
LOCAL loException
loException = .NULL.
TRY
*** Rename wc.dll file first then copy: NOTE: requires restart for new dll to actually load
IF FILE(lcWebPath + "bin\wc.dll")
ERASE (lcWebPath + "bin\wc.dll.bak")
RENAME (lcWebPath + "bin\wc.dll") TO (lcWebPath + "bin\wc.dll.bak")
ENDIF
COPY FILE("scripts\wc.dll") TO (lcWebPath + "bin\wc.dll")
IF FILE(lcWebPath + "bin\WebConnectionModule.dll")
ERASE (lcWebPath + "bin\WebConnectionModudule.dll.bak")
RENAME (lcWebPath + "bin\WebConnectionModule.dll") TO (lcWebPath + "bin\WebConnectionModudule.dll.bak")
ENDIF
COPY FILE("scripts\WebConnectionModule.dll") TO (lcWebPath + "bin\WebConnectionModule.dll")
*** Update WebControls on a development machine - won't matter on a runtime box
IF FILE("VisualStudio\WebConnectionWebControls\bin\Debug\WebConnectionWebControls.dll")
COPY FILE ("VisualStudio\WebConnectionWebControls\bin\Debug\WebConnectionWebControls.dll") TO (lcWebPath + "bin\WebConnectionWebControls.dll")
ENDIF
COPY FILE (lcWebTemplate + "westwind.css") TO (lcWebPath + "westwind.css")
WAIT WINDOW NOWAIT "Version Update Complete"
CATCH TO loException
WAIT WINDOW NOWAIT ;
"Web Resource Update Failed" + ;
loException.Message
ENDTRY
RETURN
Since this is just a script you can also copy and update this to add your own logic to handle any special updates you might need to do when a new version comes around, perhaps of your own applicatino.
Run a compiled EXE
The other alternative is to run as an EXE. Compile your project in the project manager and compile it to an exe and run the EXE.
Trust me – it’s Compilation
Several knowledgable people have come at me with this particular issue and I can insure you that the problem is DEFINITELY compilation. If you don’t think so compile the EXE and run it and that should 100% resolve the issue always.
CLEAR ALL
CLOSE ALL
DO wcDemo.exe
Old Version of Console.exe
One other thing that can cause problems is the CONSOLE.EXE which runs when Web Connection starts. There’s a Command=DO WCSTART.PRG in config.fpw, that causes the console to run when Web Connection starts and when it does it loads up it’s internally compiled versions of the various Web Connection libraries. If these versions are out of sync with the current version of Web Connection there can be problems with files not being found.
In fact, it turns out this is what is causing the problem that so many people were seeing in 5.41 – an older version of CONSOLE.EXE was accidentally shipped with Version 5.41. You can re-download version 5.41 which includes an updated file that is in sync with the current version prg files.
Alternately you can force FoxPro to release these procedures by doing:
CLEAR ALL
CLOSE ALL
Do wcDemoMain.prg && use your PRG main
Harvey Mushman
February 20, 2009