Custom assembly - Request for the permission of type 'System.Security.Permissions.FileIOPermission' failed.
I have a Sql Server Reporting Services 2005 report that access a custom assembly that I wrote. The custom assembly reads a .txt file for a connection string, and then makes calls to an Analysis Services data warehouse using ADOMD.Net.
I can run the report that calls the assembly locally without error. However, when I deploy the report and dll to the report server, I am getting the following error:
Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
I have done the following::
1. Added permission assertions to the method in my assembly (one for reading the .txt file containing the connection string, and one for writing errors to)
[FileIOPermission(SecurityAction.Assert, All = @"c:\ARA\WarehouseConnection.txt")]
[FileIOPermission(SecurityAction.Assert, All = @"c:\ARA\Errors.txt")]
2. Added this to the AssemblyInfo.cs file:
[assembly: AllowPartiallyTrustedCallers]
3. Strong named the assembly.
4. Copied the dll to the report server (C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\bin)
5. Copied the .txt file containing the connection string to a folder on the report server (C:\ARA)
6. Added the aspnet user account (with Full Control) to the security tab for the folder containing the .txt files (C:\ARA).
7. Modified the rssrvpolicy.config file on the report server to contain a new CodeGroup element for my dll (using the publickeyblob for my SN'd assembly):
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="ARACodeGroup"
Description="">
<IMembershipCondition class="StrongNameMembershipCondition"
version="1"
PublicKeyBlob="00240000048000009400000006020000002400005253413100040000010001009D2F511E1EEFE5B3958795356B9136A9B33D86E17C90EE4DE804C619634857FAE0D9C4BCD849623E8A46CC0F5B2ED5111FB292F5BCFAD74CB61624C6E3236DB8027163A80203683256C4D759BC63BF58B5B5096F9B88C8096F0E2600EB831FEBA100D32CC02892842B798851A03FD9792921D03B9BFE4FF04A1CF6D5407554B3"/>
</CodeGroup>
The strange thing is that my assembly writes to an Errors.txt file in the Catch block without any problem. But it's writing the error shown above. How could the code have a problem accessing the FileIOPermission object when it seems to be using it for writing out to the text file?
I have searched Google for the past 2 days for a resolution to this. I am at my whits end!! HELP!
My assembly code is below.
According to the instructions, I did the following on both my development laptop and on the report server:
* From a development PC, open the Control Panel, navigate to the "Administrative Tools" section
* Click on the "Microsoft .Net Framework 2.0 Configuration" applet
* Click on the "Configure Code Access Security Policy" link
* Click on the "Adjust Zone Security" link
* Keep the default "Make changes to this computer", click the "Next" button
* Click on the "Local Intranet" icon
* Move the vertical slider to "Full Trust", Click the "Next" button
* Click "Finish" at the summary screen