Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What is the meaning of E2355

231 views
Skip to first unread message

VT Venkatesh

unread,
Jul 26, 2008, 4:43:55 AM7/26/08
to
I am getting the following error
E2355: Class property accessor must be a class field or class static method

I am getting the error in
class property FilesTypesToSearch: string read get_FilesTypesToSearch;
in the class declaration given below
venkatesh
***************************************************
Site = class
strict private
class var
m_ApplicationPath: string;
public
constructor Create;
class function get_FilesTypesToSearch: string;
class function get_DynamicFilesTypesToSearch: string;
class function get_BarredFolders: string;
class function get_BarredFiles: string;
class function get_EnglishLanguage: Boolean;
class function get_ApplicationPath: string;
procedure set_ApplicationPath(Value: string);
class property FilesTypesToSearch: string read
get_FilesTypesToSearch;
class property DynamicFilesTypesToSearch: string read
get_DynamicFilesTypesToSearch;
class property BarredFolders: string read get_BarredFolders;
class property BarredFiles: string read get_BarredFiles;
class property EnglishLanguage: Boolean read get_EnglishLanguage;
class property ApplicationPath: string read get_ApplicationPath
write set_ApplicationPath;
end;
************************************************************8

Robert Giesecke

unread,
Jul 26, 2008, 7:02:25 AM7/26/08
to
VT Venkatesh wrote:
> I am getting the following error
> E2355: Class property accessor must be a class field or class static method
>
> I am getting the error in
> class property FilesTypesToSearch: string read get_FilesTypesToSearch;
> in the class declaration given below
> venkatesh
....

> constructor Create;
> class function get_FilesTypesToSearch: string;
>

That's one of these Win32-lookalike things that is biting you here.
You have to mark a class method as "static" to have a normal CLR static method.
Otherwise D.Net will emit a hidden parameter that takes the metaclass...

VT Venkatesh

unread,
Jul 26, 2008, 8:24:56 AM7/26/08
to
Robert Giesecke wrote:

> >
>
> That's one of these Win32-lookalike things that is biting you here.
> You have to mark a class method as "static" to have a normal CLR static
> method.
> Otherwise D.Net will emit a hidden parameter that takes the metaclass...

When i try I get the error
[DCC Error] uSite.pas(19): E2376 STATIC can only be used on non-virtual
class methods
Venkatesh

Robert Giesecke

unread,
Jul 26, 2008, 11:52:58 AM7/26/08
to

Well, of course. Even though D.Net tries very hard to hide a lot of what makes up .Net from you, in
the end it still has to follow its rules.
.Net has no notion of metaclasses, and the way they are impleemnte in d.Net reuire them to be passed
as a parameter to non-static class methods.
You cannot use "self" inside a static method, you cannot call non-static class methods as well. As I
said, non-static class methods require the meta class to be passed as a hidden parameter.
Static methods are stateless, and therefor they have no metaclass reference to pass to other class
methods. Hence not being able to call them.

Lionel

unread,
Jul 26, 2008, 1:38:27 PM7/26/08
to
May be it is because Delphi doesnt like get_ and set_

I have this problem with Delphi 6 : try getFilesTypesToSearch instead of
get_FilesTypesToSearch

Lionel


"VT Venkatesh" <ve...@vsnl.com> a écrit dans le message de news:
488a...@newsgroups.borland.com...

Robert Giesecke

unread,
Jul 27, 2008, 3:45:34 PM7/27/08
to
Lionel wrote:
> May be it is because Delphi doesnt like get_ and set_
>
> I have this problem with Delphi 6 : try getFilesTypesToSearch instead of
> get_FilesTypesToSearch
>

I don't think that this should be a problem in Delphi6, but it could be one in Delphi.Net.
In .Net, a property XYZ consists of nothing more than the methods get_XYZ and set_XYZ. (both with the
specialname flag)
It could very well be the case, that D.Net can't handle it when the setter/getter have these names.
So you might have to remove the underscores.
I haven't touched D.Net for too many years, so it could be that it can handle this situation now.

John Moshakis

unread,
Jul 27, 2008, 4:16:00 PM7/27/08
to
VT Venkatesh wrote:

> I am getting the following error
> E2355: Class property accessor must be a class field or class static
> method

Hi Venkatesh,

I think you need to add static to the end of all the getters and setters

class function get_FilesTypesToSearch: string;static;
class function get_DynamicFilesTypesToSearch: string;static;
class function get_BarredFolders: string;static;
class function get_BarredFiles: string;static;
class function get_EnglishLanguage: Boolean;static;
class function get_ApplicationPath: string; static;

class procedure set_ApplicationPath(Value: string);static;

Access to the class var in the getter and setter would be like this

result:=Site.m_ApplicationPath;

Cheers,
John


--
Blog: http://blog.moshine.com/

John Moshakis

unread,
Jul 27, 2008, 4:24:36 PM7/27/08
to
Lionel wrote:

> May be it is because Delphi doesnt like get_ and set_
>
> I have this problem with Delphi 6 : try getFilesTypesToSearch
> instead of get_FilesTypesToSearch
>

Hi Lionel,

If you don't use the get_ and set_ pattern Delphi.Net will generate
them for you

ie

property SomeProperty:string read FSomeProperty write FSomeProperty;

If you open up reflector you will see these methods. You can also call
them yourself

instance.set_SomeProperty('John');

Or you can do it yourself

procedure set_SomeProperty(Value:string);
function get_SomeProperty():string;
published

property SomeProperty:string read get_SomeProperty write
set_SomeProperty;

Lionel

unread,
Jul 28, 2008, 3:45:16 AM7/28/08
to
Sorry, i meant Delphi BDS 2006, not Delphi 6

under Delphi BDS 2006 do not use get_ nor set_ or you will get errors.

so, under Delphi BDS 2006 : write getFilesTypesToSearch instead of
get_FilesTypesToSearch

i guess the same problem will occur on Delphi 2007.

Lionel

"Lionel" <Lionel...@atscan.fr> a écrit dans le message de news:
488b...@newsgroups.borland.com...

0 new messages