all groups > vj# > may 2004 >
You're in the

vj#

group:

System.Security in VJ#



System.Security in VJ# Sameeksha
5/11/2004 11:06:03 PM
vj#: 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 Tex

[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
ge

return _text

[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
se

_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 i

Re: System.Security in VJ# Lars-Inge Tønnessen
5/13/2004 11:29:52 PM
I don't think it will change anything. J# must run with "FullTrust" anyway.

http://msdn.microsoft.com/library/en-us/dv_vjsharp/html/vjgrfSecuritySemanticsForApplicationsWrittenInVisualJNET.asp


Regards,
Lars-Inge Tønnessen
www.larsinge.com

RE: System.Security in VJ# Amit.vjc NO[at]SPAM online.microsoft.com
5/14/2004 8:48:14 AM
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]
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]
AddThis Social Bookmark Button