Index: ExtPascal.pas
===================================================================
--- ExtPascal.pas	(revision 819)
+++ ExtPascal.pas	(working copy)
@@ -44,7 +44,7 @@
 
 // Enabling WebServer directive ExtPascal can be used within an embedded Indy based WebServer
 {$IFNDEF SERVICE}
-{.$DEFINE WebServer}
+{$DEFINE WebServer}
 {$ENDIF}
 
 // Uses ext-all-debug.js, format all JS/CSS source code to facilitate debugging on browser and locates line error if using Firefox on AJAX responses
@@ -54,7 +54,7 @@
 {.$DEFINE CacheFly}
 
 // Uses DebugExtJS to load ext-all-debug.js library instead ext-all.js to debugging purposes
-{.$DEFINE DebugExtJS}
+{$DEFINE DebugExtJS}
 
 interface
 
@@ -242,6 +242,8 @@
   TMixed = TExtObjectList;
 //DOM-IGNORE-END*)
 
+  procedure InitTextMetrix;
+
 const
   DeclareJS    = '/*var*/ '; // Declare JS objects as global
   CommandDelim = #3;         // Internal JS command delimiter
@@ -785,7 +787,7 @@
       (IfThen(CustomJS = '', '', CustomJS + ^M^J) +
       'Ext.onReady(function(){' +
       'Ext.get("loading").remove();' +
-      'Ext.BLANK_IMAGE_URL="' + ExtPath + '/resources/images/default/s.gif";TextMetrics=Ext.util.TextMetrics.createInstance("body");'+
+      'Ext.BLANK_IMAGE_URL="' + ExtPath + '/resources/images/default/s.gif";TextMetrics=Ext.util.TextMetrics("body");'+
       'function AjaxError(m){Ext.Msg.show({title:"Ajax Error",multiline:true,msg:m,icon:Ext.Msg.ERROR,buttons:Ext.Msg.OK});};' +
       {$IFDEF DEBUGJS}
       'function AjaxSource(t,l,s){var w=new Ext.Window({title:"Ajax error: "+t+", Line: "+' + IfThen(Browser=brFirefox, '(l-%%)', '"Use Firefox to debug"') +
@@ -930,7 +932,10 @@
 
 // Set an unique <link TExtObject.JSName, JSName> using <link TExtThread.GetSequence, GetSequence>
 procedure TExtObject.CreateJSName; begin
-  FJSName := 'O' + IdentDelim + TExtThread(CurrentWebSession).GetSequence + IdentDelim;
+  if CurrentWebSession = nil then
+    FJSName := 'O' + IdentDelim + '0' + IdentDelim
+  else
+    FJSName := 'O' + IdentDelim + TExtThread(CurrentWebSession).GetSequence + IdentDelim;
 end;
 
 {
@@ -1906,7 +1911,12 @@
   Result := TExtObject(TExtThread(CurrentWebSession).GarbageFind(CurrentWebSession.Query[ParamName]));
 end;
 
+procedure InitTextMetrix;
 begin
   ExtUtilTextMetrics := TExtUtilTextMetrics.Create('body');
   ExtUtilTextMetrics.FJSName := 'TextMetrics';
+end;
+
+begin
+
 end.