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=18.104.22.168, 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:
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):
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.