Главная страница | назад





Article #27949: Unofficial WebSnap updates and bug fixes

Unofficial WebSnap Bug Fixes

By Corbin Dunn cdunn@nospam.borland.com
Remove the nospam. from my email address when mailing me

Unofficial fixes — page 2 (these are post service pack 2 issues)

In general, applying these fixes require you to rebuild some of the VCL. The easiest way to do this, is to go to Tools | Environment Options and from the Library tab add $(DELPHI)\Source\Internet to your Library Path.

These fixes are unofficial, are not supported by Borland, and are to be used at your own risk.

Quick Jumps:
Crashes or hangs in your Web Application when it shuts down (ie: ISAPI dll is unloaded, CGI exits, or Apache is stopped).
Cannot perform this operation on a closed dataset
Transparent tags in any TPageProducer will have spaces "eaten"...
WebAppDebugger: Exception EOleException in module ModuleName.exe. Catastrophic failure
The OnPrepareStrings event of TCustomStringsValuesList never gets called.
"Runtime Error 217" when unloading an ISAPI dll/CGI (or crash of webserver on unloading of the app)
WebSnap apps leak memory if any of the events in the SessionsService are used
When assigning things in script, yo uget an access violation at address xxx in module 'oleaut32.dll'. Read of address 00000000
The application called an interface that was marshalled for a different thread
If you use the AdapterPageProducer to generate script, the SelOptions JScript will not show a value of 0...
An error occurred while attempting to initialize the Borland Database Engine (error $2B05)
If you are using the TDatasetAdapter, and the keyfield is a string which contains a single or double quote in it, it will not be properly encoded in actions.
Calculated fields in a dataset cause the TDatasetAdapter to always raise the exception "Field %s changed by another user".
Where are some good articles and updated documentation on WebSnap?
More additional information
On XP: Cannot create script engine: "SignedJavaScript". Error: 80040154
Memory leak fixes in WebSnap
AV's when using the TDatasetAdapter and an exception is raised...
AV's when using MIDAS and TSocketConnection with WebSnap

AV's when using MIDAS and TSocketConnection with WebSnap (upon shutdown of the application).
This is fixed in Delphi 6 update pack 2.

When using the TDatasetAdapter, AV's will happen if an exception is raised in the opening/closing/next/prior of a dataset.
This is fixed in Delphi 6 update pack 2.

Memory leak fixes. TAutoObjectFactory objects that are created in WebAuto.TAbstractScriptComServerObject.RegisterScriptClass are never freed. Another 84 bytes are lost on each request with another bug.
This is fixed in Delphi 6 update pack 2.

The error: "Cannot perform this operation on a closed dataset" will happen if you click the Prior button in a WebSnap application, and you don't have any keyfields set.
This is fixed in Delphi 6 update pack 2.

Transparent tags in any TPageProducer will have spaces "eaten" in the tags if the ScriptEngine property is anything but blank. For instance, <#TagName ParamName="Value"> will become <#TagNameParamName="Value">.
This is fixed in Delphi 6 update pack 2.

After applying the Delphi 6 update pack 1 attempting to recompile and use the Web App Debugger always gives: "Exception EOleException in module ModuleName.exe. Catastrophic failure".
This is fixed in Delphi 6 update pack 2.

The OnPrepareStrings event of TCustomStringsValuesList never gets called.
This is fixed in Delphi 6 update pack 2.

"Runtime Error 217" when unloading an ISAPI dll or the termination of a CGI application happens. Or, your web server simply crashes when trying to unload a WebSnap ISAPI dll.
This is fixed in Delphi 6 update pack 2.

WebSnap apps leak memory if any of the events in the SessionsService are used (OnEndSession or OnStartSession).
This is fixed in Delphi 6 update pack 2.

If you try to assign something to an Adapter field's value in script, you get an:
[Error] Unit2.htm(1): Access violation at address 779DB637 in module 'oleaut32.dll'. Read of address 00000000

Or, you try to assign something to the adatper itself, such as: <% Modules.PageProducerPage2.Adapter1 = 'alksjfkljsadf' %>
This is fixed in Delphi 6 update pack 2.

When running your WebSnap app you sometimes get:"The application called an interface that was marshalled for a different thread"
Or:
The error: -2147417842 (0x8001010e) is returned from any WebSnap application compiled as an ISAPI dll and run under IIS5 (Windows 2000) with the Application Protection on that directory is set to "Medium (Pooled)".
Note: This is fixed in Delphi 6 update pack 2, by having the Wizard generate this code for you. If you have existing apps, you will still have to apply this fix

The reason this happens is because the CoInitFlags are not being set to COINIT_MULTITHREADED for an ISAPI dll (but, it is required!).


Add the following to the uses list of the main .dpr file:
ActiveX, ComObj
and have the following in the begin..end:
begin
CoInitFlags := COINIT_MULTITHREADED;
Application.Initialize;
...
CoInitFlags MUST be set before Applicaiton.Initialize.

If you use the AdapterPageProducer to generate script, the SelOptions JScript will not show a value of 0 for a given name/value pair with a TDatasetValuesAdapter. For example, if you have a Value of 0 in the database, you will see:

<select size="0" name="A">
<option>Bug</option>
// ^^^^^^ MUST BE <option value= "0">Bug</option> !!!!!
<option value="1">A</option>
<option selected value="2">B</option>
</select>
This is fixed in Delphi 6 update pack 2.

When using the BDE, I get the following error when starting my web application: "An error occurred while attempting to initialize the Borland Database Engine (error $2B05)"

Note: This is a setup issue, not a Delphi programming problem. Cause: This error happens because the anonymous user that IIS starts your process as does not have permission to write to some temp directories (Typically, for security reasons, it can't write to the directory where inetinfo.exe is located in your System32\inetsrv directory.)

Solution: The Paradox tables were not designed for multiple users hitting the database at the same time. The best solution is to use a SQL based database, such as Interbase, Oracle, or MS SQL Server.
If you must use Paradox and the BDE, then be sure to have a TSession on your WebDataModule. Set AutoSessionName to true. The key thing is to set the NetFileDir and PrivateDir to something that the anonymous IIS account can access. A good solution would be to set the NetFileDir to: C:\Temp\Net and the PrivateDir to: C:\Temp. The two cannot point to the same directory. In addition, it is best to uniquly set the PrivateDir for each webmodule, in the OnCreate event (typically, you will create a directory based on the current thread id, and set the PrivateDir to this). Otherwise, you may see each other's data from different threads. However, the NetDir MUST be shared across all processes and threads.

Next, you must give the IUSR_MACHINE_NAME and IWAM_MACHINE_NAME accounts full read and write permissions to the following directories:
1. The BDE directory
2. The base directory for your NetDir and PrivateDir
3. Your actual temp directory, probably C:\WINNT\Temp
4. Your directory that contains the database files
5. If all else fails, give read permissions to C:\WINNT, and then write permissions to C:\WINNT.

If you are using the TDatasetAdapter, and the keyfield is a string which contains a single or double quote in it, it will not be properly encoded in actions. This causes javascript errors on the client side browser, and the inability to do a locate on given records with quotes in the keyfield name.
This is fixed in Delphi 6 update pack 2.

Calculated fields in a dataset cause the TDatasetAdapter to always raise the exception "Field %s changed by another user". It is not possible to update a webpage using the TDatasetAdapter if the dataset contains calculated fields.
This is fixed in Delphi 6 update pack 2.

On XP, WebSnap apps give: Cannot create script engine: "SignedJavaScript". Error: 80040154
This is fixed in Delphi 6 update pack 2.

In any WebBroker application compiled with Delphi 6 update pack 1, the following symptoms may happen when unloading an ISAPI dll, exiting a CGI, closing down a WebAppDebugger project, or stopping Apache that contains a DSO:
access violations, runtime errors, strange exceptions being raised.
This is fixed in Delphi 6 update pack 2.

Where are some good articles and updated documentation on WebSnap?

WebSnap Server-side Scripting

New help files

UsingWebSnap.pdf

A database-enabled Web user list

Getting started with WebSnap in Delphi 6 Enterprise

Loggin' in ain't hard to do

Paging Dr. WebSnap!

Persistent user sessions in WebSnap

Access rights in WebSnap

WebSnap is now in session

WebSnap: using Sessions and TStringsValuesList and server side includes (source code from corbin)

WebSnap: Guestbook source code (Kylix 2, but should work under Delphi 6)

More additional information

The WebSnap Pack by Jimmy Tharpe provides the following free (postcard-ware) components to enhance WebSnap (see his website for more information):

  • TDBWebUserList — A replacement for TWebUserList that validates users through a database.
  • TudEndUserSessionAdapter — A replacement for TEndUserSessionAdapter that adds EndUser.DisplayName.
  • TudLoginFormAdapter — A replacement for TLoginFormAdapter.
  • TudStringsValuesList — A replacement for TStringsValuesList.

Last Modified: 27-FEB-02