I have developed my clr integrated call according to the following logic:
1) call a SSRS report
2) save the report as a PDF in a specific folder location using foll code:
// get pdf of report
Byte results = rsExec.Render("PDF", deviceInfo,
out extension, out encoding,
out mimeType, out warnings, out streamIDs);
FileStream fs = new FileStream(@"C:\Temp\PDF\rep.pdf", FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(results, 0, results.Length);
3) I have created by assembly using sgen fine,
4) created the mapped stored proceedure to call the assembly defined code
CREATE PROCEDURE dbo.testSP
AS EXTERNAL NAME
5) However, whenever I exculte the SP, an error is always thrown as per below:
Msg 6522, Level 16, State 1, Procedure sp_clr, Line 0
A .NET Framework error occurred during execution of user-defined routine or aggregate "testSP":
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at emlPDFStatement.StoredProcedures.sp_clr(String cust)
6) Because my clr code is writing a file, the error is most probably related to a security issue. I have used credidential that has the requiired rights.
7) I have googled the error and applied recommeded solutions but wihout any success.
I would be very much if any one could advise on the resolution or better point me to a small project that works fine along the above lines.
Thank you very much in advance.