¿Cómo implementar IOTAProjectCompileNotifier de Delphi's ToolsAPI?

Estoy usando Delphi XE IDE. Creo un notificador para implementar IOTACompileNotifier. Después de instalar el experto en el IDE. El código funciona bien cuando compilo mi proyecto. El notificador está funcionando para ProjectCompileStarted.

La segunda vez que compilo mi proyecto, el indicador de IDE de Delphi:

[Fatal Error] Access violation at address 21B7FBED in module 'delphicoreide150.bpl'. Read of address 00000000

Aunque parece extraño que realizo:

var i: integer;
begin
  i := Project.ProjectBuilder.AddCompileNotifier(TProjectCompileNotifier.Create);
  Project.ProjectBuilder.RemoveCompileNotifier(i);
end;

in notificador. Solo quiero mostrar Agregar y quitar el notificador de compilación para ProjectBuilder parece que no funciona correctamente sin importar cómo lo use.

Por favor, indique cómo debo implementar IOTAProjectCompileNotifier.

Gracias

Aquí está el código fuente completo:

type
  TProjectCompileNotifier = class(TInterfacedObject, IOTAProjectCompileNotifier)
  protected
    procedure AfterCompile(var CompileInfo: TOTAProjectCompileInfo);
    procedure BeforeCompile(var CompileInfo: TOTAProjectCompileInfo);
    procedure Destroyed;
  end;

  TCompileNotifier = class(TInterfacedObject, IOTACompileNotifier)
  protected
    procedure ProjectCompileStarted(const Project: IOTAProject; Mode: TOTACompileMode);
    procedure ProjectCompileFinished(const Project: IOTAProject; Result: TOTACompileResult);
    procedure ProjectGroupCompileStarted(Mode: TOTACompileMode);
    procedure ProjectGroupCompileFinished(Result: TOTACompileResult);
  end;

procedure TCompileNotifier.ProjectCompileStarted(const Project: IOTAProject;
  Mode: TOTACompileMode);
var i: integer;
begin
  i := Project.ProjectBuilder.AddCompileNotifier(TProjectCompileNotifier.Create);
  Project.ProjectBuilder.RemoveCompileNotifier(i);
end;

var i: integer;

initialization
  i := (BorlandIDEServices as IOTACompileServices).AddNotifier(TCompileNotifier.Create);
finalization
  (BorlandIDEServices as IOTACompileServices).RemoveNotifier(i);
end.

Respuestas a la pregunta(3)

Su respuesta a la pregunta