The syntax you used is for attaching the attribute on the accessor method
not on the property. For example:
Attaching on the accessor:
public override string Text
{
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
get
{
return _text;
}
}
Attaching on the property itself. This gives an error:
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
public override string Text
{
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
get
{
return _text;
}
}
The same can be achieved in J# too. The sample code that is posted is:
** @property()
*/
/** @attribute System.Security.Permissions.PermissionSet(
System.Security.Permissions.SecurityAction.Demand, Name =
"FullTrust")
*/
public String get_Text()
{
return _text;
}
This attaches the attribute on the property itself hence the error. To
attach on the accessor, use @attribute.method
** @property()
*/
/** @attribute.method System.Security.Permissions.PermissionSet(
System.Security.Permissions.SecurityAction.Demand, Name =
"FullTrust")
*/
public String get_Text()
{
return _text;
}
Here is a link to attribute attaching syntax.
http://msdn.microsoft.com/library/en-us/dv_vjsharp/html/vjgrfVisualJLanguage Overview.asp?frame=true)
--------------------
[quoted text, click to view] >Thread-Topic: System.Security in VJ#
>thread-index: AcQ35zT/cOfuzPNuRteNM9RVqpOhkg==
>X-WN-Post: microsoft.public.dotnet.vjsharp
>From: =?Utf-8?B?U2FtZWVrc2hh?= <anonymous@discussions.microsoft.com>
>Subject: System.Security in VJ#
>Date: Tue, 11 May 2004 23:06:03 -0700
>Lines: 42
>Message-ID: <74120171-CC97-44B7-9F38-5330A542FC7E@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.dotnet.vjsharp
>Path: cpmsftngxa10.phx.gbl
>Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.vjsharp:6023
>NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
>X-Tomcat-NG: microsoft.public.dotnet.vjsharp
>
>A property in C# is having System.Security.Permissions.PermissionSet
Attribute. When I try to convert the same with same permissionset attribute
in VJ#, the code does not compile saying that "Attribute
'System.Security.Permissions.PermissionSetAttribute' is not valid on this
declaration".
Following is the property written in C#:
public override string Text
{
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
get
{
return _text;
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
set
{
_text = value;
}
}
And following is its conversion into equivalent VJ# code:
/** @property()
*/
/** @attribute System.Security.Permissions.PermissionSet(
System.Security.Permissions.SecurityAction.Demand, Name =
"FullTrust")
*/
public String get_Text()
{
return _text;
}
/** @property()
*/
/** @attribute System.Security.Permissions.PermissionSet(
System.Security.Permissions.SecurityAction.Demand, Name =
"FullTrust")
*/
public void set_Text(String value)
{
_text = value;
}
If I remove the attribute declaration it compiles and executes fine and the
output matches with the C# output. But logically is it alright to remove
the permissionset attribute declaration? Will it affect the meaning of the
code?
Please reply if anybody knows it
Sameeksha
[quoted text, click to view] >