Como implementar o IOTAProjectCompileNotifier do Delphi's ToolsAPI?

Estou usando Delphi XE IDE. Eu crio um notificador para implementar IOTACompileNotifier. Depois de instalar o especialista no IDE. O código funciona bem quando eu compilo meu projeto. O notificador está funcionando para ProjectCompileStarted.

A segunda vez que compilei meu projeto, o prompt do Delphi IDE:

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

Embora pareça estranho que eu execute:

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

in notifier. Eu só quero mostrar o notificador de compilação Adicionar e Remover para o ProjectBuilder parece não funcionar corretamente, não importa como eu us

Por favor, informe como devo implementar o IOTAProjectCompileNotifie

Obrigado

Aqui está o código fonte 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.

questionAnswers(3)

yourAnswerToTheQuestion