Reputation: 530
I'm receiving an error when building the IdMessageHelper.pas
unit in the IndyProtocols90
package. All instances of LoadFromStream
and LoadFromFile
are claiming there is an issue with the signature:
[Error] IdMessageHelper.pas(78): E2250 There is no overloaded version of 'LoadFromStream' that can be called with these arguments
procedure Internal_TIdMessageHelper_LoadFromStream(AMsg: TIdMessage; AStream: TStream;
const AHeadersOnly: Boolean; const AUsesDotTransparency: Boolean);
var
LMsgClient: TIdMessageClient;
begin
if AUsesDotTransparency then begin
AMsg.LoadFromStream(AStream, AHeadersOnly);
end else
begin
// clear message properties, headers before loading
AMsg.Clear;
LMsgClient := TIdMessageClient.Create;
try
Internal_TIdMessageClientHelper_ProcessMessage(LMsgClient, AMsg, AStream, AHeadersOnly, False);
finally
LMsgClient.Free;
end;
end;
end;
I see that IdMessageHelper
is new to this version, but the method that's being called (IdMessage.LoadFromStream
for example), the arguments for it haven't changed from the last few versions - at least not for the ones that I have the source.
procedure TIdMessage.LoadFromStream(AStream: TStream; const AHeadersOnly: Boolean = False);
var
LMsgClient: TIdMessageClient;
begin
// clear message properties, headers before loading
Clear;
LMsgClient := TIdMessageClient.Create;
try
LMsgClient.ProcessMessage(Self, AStream, AHeadersOnly);
finally
LMsgClient.Free;
end;
end;
I'm pretty sure I removed all previous versions and packages since this was a clean install of D2005.
Upvotes: 1
Views: 194
Reputation: 597941
The IdMessageHelper
unit introduces new LoadFrom...()
and SaveTo...()
methods for the TIdMessage
component, to add an AUsesDotTransparency
parameter when loading/saving emails.
In Delphi 2005 and later, it does this by defining a class helper (which is a feature introduced in Delphi 2005) to add new methods to the TIdMessage
component without having to modify the IdMessage.pas
unit itself. This allows Indy to let people use familiar IdMessage1.LoadFrom...()
and IdMessage1.SaveTo...()
syntax when using the new functionality 1.
Things were done this way so as not to cause interface breaking changes in the IdMessage
unit itself. I blogged about this new addition at the time the IdMessageHelper.pas
unit was first added to Indy:
In your case, the error message is complaining about Line 78:
AMsg.LoadFromStream(AStream, AHeadersOnly);
That line is the new 3-parameter TIdMessageHelper.LoadFromStream()
method attempting to call the pre-existing 2-parameter TIdMessage.LoadFromStream()
method when AUsesDotTransparency
is True:
procedure TIdMessage.LoadFromStream(AStream: TStream; const AHeadersOnly: Boolean = False);
I have tested this new class helper in later Delphi versions and it works fine for me. You should not be getting a compiler error, as there should not be any ambiguity.
However, I have not tested the class helper in Delphi 2005 specifically (as I do not have that version installed), so it is possible that the compiler error could be indicating that class helpers (being a new language feature at the time) were still a little buggy, and were fixed later on.
If you can't find the cause of the ambiguity, you can work around the issue by modifying IdMessageHelper.pas
to undefine HAS_CLASS_HELPER
for Delphi 2005 1, and then recompile Indy again.
1: In older versions of Delphi where class helpers are not available, IdMessageHelper.pas
also defines several standalone TIdMessageHelper_LoadFrom...()
and TIdMessageHelper_SaveTo...()
functions, so people can still utilize the new AUsesDotTransparency
functionality, just with a less-desirable calling syntax.
EDIT: it turns out that class helpers were very buggy in Delphi 2005, and were not officially supported until Delphi 2006:
Class helpers have now been formally introduced in the Win32 compiler [in Delphi 2006]. In Delphi 2005 class helpers were not formally available, and although you could use them they were actually quite buggy. It was quite easy to get internal compiler errors while using them, nothing you could complain to with Borland about as this feature was not officially supported.
So, I have now disabled the TIdMessageHelper
helper class in Delphi 2005, and have updated the above mentioned blog article accordingly.
Upvotes: 3