Wednesday, March 21, 2012

FileIOPermission for Custom Assembly

I am using a strong-named custom assembly to which I have assigned 'Full
Trsut' in both the rspreviewpolicy.config as well as rssrvrpolicy.config.
Now, I have introduced a function in my assembly that requires reading some
settings from a file...The error message I see when executing that function
is "Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed".
If the assembly already has Full Trust permissions, then should it not have
full access to all resources? Or do I need to create a FileIOPermission set?
I tried the latter, but it does not seem to work for me either...Please
help...You would need to give the data extension permissions for File IO
e.g.
<PermissionSet class="abcg"
verion="1" Name="FileSharePermissionSet"
<IPermission class="FileIOPermission"
version="1"
Unrestricted="true" />
</PermissionSet>
"Aparna" wrote:
> I am using a strong-named custom assembly to which I have assigned 'Full
> Trsut' in both the rspreviewpolicy.config as well as rssrvrpolicy.config.
> Now, I have introduced a function in my assembly that requires reading some
> settings from a file...The error message I see when executing that function
> is "Request for the permission of type
> System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089 failed".
> If the assembly already has Full Trust permissions, then should it not have
> full access to all resources? Or do I need to create a FileIOPermission set?
> I tried the latter, but it does not seem to work for me either...Please
> help...
>|||You see, I tried doing something similar and it is not working.
Here is my named permission set:
<PermissionSet
class="NamedPermissionSet"
version="1"
Unrestricted="true"
Name="TestPermissionSet" >
<IPermission
class="FileIOPermission"
version="1"
Unrestricted="true"/>
<IPermission
class="EnvironmentPermission"
version="1"
Unrestricted="true"/>
</PermissionSet>
I added both FileIOPermission as well as Environment Permission because the
code reads a file and also calls Environment.ExpandEnvironmentVariables().
The code group looks as follows:
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="TestPermissionSet"
Name="TestCode">
<IMembershipCondition
class="StrongNameMembershipCondition"
version="1"
PublicKeyBlob="blahblahblah"/>
</CodeGroup>
Still no luck!!
~Aparna.
"Mac" wrote:
> You would need to give the data extension permissions for File IO
> e.g.
> <PermissionSet class="abcg"
> verion="1" Name="FileSharePermissionSet"
> <IPermission class="FileIOPermission"
> version="1"
> Unrestricted="true" />
> </PermissionSet>
>
> "Aparna" wrote:
> > I am using a strong-named custom assembly to which I have assigned 'Full
> > Trsut' in both the rspreviewpolicy.config as well as rssrvrpolicy.config.
> > Now, I have introduced a function in my assembly that requires reading some
> > settings from a file...The error message I see when executing that function
> > is "Request for the permission of type
> > System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
> > Culture=neutral, PublicKeyToken=b77a5c561934e089 failed".
> >
> > If the assembly already has Full Trust permissions, then should it not have
> > full access to all resources? Or do I need to create a FileIOPermission set?
> > I tried the latter, but it does not seem to work for me either...Please
> > help...
> >sql

No comments:

Post a Comment