views:

158

answers:

1

After adding a IdUDPServer to my form and trying to put some code into the OnUDPRead event, I'm not able to add any component to my form at design time, nor can I run the application.

this is the error i'm getting

is there any way to solve this ?

+1  A: 

There are two bugs with this event handler. To fix them, you can

  • remove the System. from TArray<System.Byte> (in the interface and implementation)
  • add IdSocketHandleto the uses list in the interface

I have not investigated further but after these changes the code can be compiled.

So the full code would like be

unit Unit12;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, 
  IdSocketHandle, // <-- added
  IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient, IdUDPServer;

type
  TForm12 = class(TForm)
    IdUDPClient1: TIdUDPClient;
    IdUDPServer1: TIdUDPServer;
    procedure IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
      AData: TArray<Byte>; ABinding: TIdSocketHandle);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form12: TForm12;

implementation

{$R *.dfm}

procedure TForm12.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
  AData: TArray<Byte>; ABinding: TIdSocketHandle);
begin
  //
end;
mjustin
The above code compiles, but it doesn not work. I`ve made a simple app which uses 2 `IdUDPServer` comps, one to broadcast and one to Listen, works as expected in Delphi 2010 but if brought in DelphiXE and builded does not work, not even if i replace `TArray<Byte>` with `TBytes` as in D2010
Alin Sfetcu
Maybe an update to a newer release of Indy 10 helps, the 'unofficial' daily snapshots are available at ftp://ftp.fulgan.com/ZIP (current: Indy10_4454.zip)
mjustin
i have tried `Indy10_4454.zip` and `Indy10Tiburon_4448.zip` with no luck, same behavior.
Alin Sfetcu
I have just checked in an update that makes the IDE auto-add the missing IdSocketHandle unit reference. But the TArray issue is a bug in the IDE and Embarcadero will have to address that one in a future Update Pack.
Remy Lebeau - TeamB