System Illegally Re-Entered

I have a routine that creates forms dynamically from their classname.
Unfortunately, I get intermittent "System Illegally Reentered " crashes.

When a new form is required for the application. It is defined as
inheriting from TSMSForm, my base form class.

In the unit that defines the form, I have a RegisterClasss staement in
the initialization section that registers the form type - that way, I
don't need to refer to form units in the uses clause.

I can then instantiate the form like this :

procedure TFormFactory.CreateForm(ViewWanted : TView);
type
  TFormClass           = class of TSMSForm;

var
  ThisPersistentClass : TPersistentClass;
  ThisFormClass       : TFormClass;
  ThisForm            : TSMSForm;

begin
  {retrieve form class from its name}
  ThisPersistentClass:=getClass(ViewWanted.formClass);

  if thisPersistentClass=nil
   then
    begin
    messageDlg('GetClass was nil' +
          viewWanted.formclass, mtError,[mbOK],0);
     exit;
    end;

  {cast the persistent class returned from GetClass to a class of
TSMSForm}
  ThisFormClass:=TFormClass(ThisPersistentClass);

  {create instance of that particular class of form}
  if thisFormClass=nil
   then
     begin
     messageDlg('Could not cast to a class of ' +
        ThisPersistentClass.classname,
        mtError,[mbOK],0);
     exit;  
     end
   else
     begin
      messageDlg('About to create an instance of : ' +
        ThisFormClass.classname,
        mtError,[mbOK],0);
     ThisForm:= ThisFormClass.create(frmMain);
     end;

This routine works fine, but crashes intermittently with a "System
Illegally Re-Entered"  messsage on the line -

ThisForm:= ThisFormClass.create(frmMain);

The problem seems to arise after previous instances of the form type
have been freed. My question is, is this code OK? If it is, I can start
looking for a bug elsewhere in the program.    
--
K M Payne