SQL Server Reporting Services 2008 with custom DLL - SecurityPermission error
Hi.I am getting the following error when I try to call a function in a custom DLL from a SSRS report running within Visual Studio 2008. The function in question simply reads text out of a text file.---------------------------------------------------------------[rsRuntimeErrorInExpression] The Value expression for the textrun Textbox1.Paragraphs[0].TextRuns[0] contains an error: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.Preview complete -- 0 errors, 1 warnings---------------------------------------------------------------I am running Windows Vista SP1, SQL Server 2008 Standard Edition and SSRS 2008. I am creating the reports in Visual Studio 2008 Professional Edition. I am logged in as a standard user (as opposed to an Administrator), although I still have admin rights in SQL Server. UAC is turned on in Vista.I have gone through every step as outlined in these tutorials http://www.c-sharpcorner.com/UploadFile/balajiintel/CustomAssemblyinRS06302005081435AM/CustomAssemblyinRS.aspx?ArticleID=f3904516-e30a-401a-aa01-463636d78f18(in particular the second half about a complex custom assembly) and http://blogs.sqlxml.org/bryantlikes/articles/824.aspx. Note that I have also followed many other articles and tutorials, but every time I get the same error.The only major change from the first tutorial is that I put the SimpleDLL.dll file in the C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies and C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer\bin directories (since I was working from Visual Studio 2008). Also my rssrvpolicy.config file was in C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer.I realise that the articles linked to above are both using SQL Server 2000 (and maybe 2005), but I was not able to find any more recent tutorials for SQL Server 2008 or SSRS 2008. I can only imagine that something has changed in SQL Server 2008, SSRS 2008 or Windows Vista that is causing the problem. But really I am stumped as to how to fix the issue. In every case I can get all the way through the steps without any problems, but the very last part doesnt work for me.While the above tutorials simply read text from a file, what I actually need to do is more complex. An expression in a SSRS report will call a DLL function which in turn calls a WCF service function. The service function accepts a value and returns a street address. I think I had this pretty much working from a report, expect I kept running into the error mentioned above (this is why I turned to the simpler tutorials in the first place).Can anybody explain what is causing the error and how I can get around it? Alternatively, if you know of a better or easier way that I can accomplish the same thing (i.e. call a WCF function from an expression in a SSRS report), please let me know.I have a simple tutorial project that I have been working with, that I can send to someone if required.Thanks in advance for any help!!
April 2nd, 2009 7:30am

Hi, Inthe Reporting Service, using System.IO to read a fileis an unattended report processing. Unattended report processing refers to any report execution process that is triggered by an event (either a schedule-driven event or data refresh event) rather than a user request. The report server uses the unattended report processing account to log on to the computer that hosts the external data source. This account is necessary because the credentials of the Report Server service account are never used to connect to other computers. Reporting Services provides a special account named Execution Account that is used for unattended report processing and for sending connection requests across the network. To solve the issue, you could special a domain account for Execution Account. If specifying the execution account does not help, could you please use the following steps to debug the Extension, and post the detailed error here: 1. Open the custom extension project. 2. Click the file menu Debug -- > Attach to process, and select the process aspnet_wp.exe. 3. Toggle BreakPoint at the point you want. 4. Open the Report Server by using http://<servername>/reportserver 5. Catch the errors, and post them here. For more information about How to configure the Account, please see Configuring the Unattended Execution Account in SQL Server Books Online. Thanks, Jin Jin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
April 3rd, 2009 9:28am

Jin,your answer does not seem to apply, since Developer Guy's problem was tied to rendering within the IDE. I have a similar problem in that I get the permissions error only when I attempt to run the preview within the IDE -- if I run via the reporting website, it works fine.So what is the expected gain? Are you implying that running in preview mode in the IDE is related to running an unattended report?
April 13th, 2009 7:13pm

Using Preview in BI Development Studio 2008 now always requires the same security policy changes that you have to apply on a RS 2008 server. The error happens because your custom assembly requires permissions higher than "ExecutionOnly" permissions - you have to grant additional permissions in RSPreviewPolicy.config in the VS folder and assert the permissions in your custom assembly implementation.Btw, BI Development Studio 2005 only enforces security policy settings if you run the stand-alone preview (Ctrl+F5), but not when running the built-in preview (F5).HTH,RobertRobert Bruckner http://blogs.msdn.com/robertbruckner This posting is provided "AS IS" with no warranties, and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2009 5:33am

Im very sorry for the late reply! I had expected to get alerts via e-mail when this thread was updated but I never received any. I assumed that nobody had bothered replying :-P Ill check the thread more often from now on. Also thanks to everyone for the replies so far. While my original post was related to running reports from within the IDE, it is also not working for me in a browser at http://localhost/reportserver, nor via the Report Viewer control in a Windows Forms application. Really I would just like to get it working in any scenario at this point. Jin, Im not sure if it matters, but my test project does not send anything over the network as everything is running on the same machine. So Im not sure if specifying an Execution Account will help. I did try to debug the extension as you suggested, but for whatever reason aspnet_wp.exe doesnt show up as one of the available processes. This might be because IIS and ASP.NET are not installed on this computer. Robert, I have added the following to the RSPreviewPolicy.config file at C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies. This is the place where I thought there might be problem of some sort. I had been specifying FullTrust instead of ExecutionOnly, which I assume is correct. However I am not clear on the rest of the values (such as where to place the DLL for Visual Studio 2008 or alternatively for SSRS 2008), where to place the code group in the file, and so on. Does this look correct? <CodeGroup class="FirstMatchCodeGroup" version="1" PermissionSetName="FullTrust" Name="MyCustomAssemblyCodeGroup" Description="A special code group for my custom assembly."> <IMembershipCondition class="UrlMembershipCondition" version="1" Url="C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer\bin\SimpleDLL.dll"/></CodeGroup> This has been placed at the end of the file, right before the following: </CodeGroup> </PolicyLevel> </policy> </security> </mscorlib></configuration> I am using this code to assert the permissions in the custom DLL (as per the tutorial I was following at http://www.c-sharpcorner.com/UploadFile/balajiintel/CustomAssemblyinRS06302005081435AM/CustomAssemblyinRS.aspx?ArticleID=f3904516-e30a-401a-aa01-463636d78f18): public static string ReturnString() { FileIOPermission fileReadPerm = new FileIOPermission(FileIOPermissionAccess.Read, @"C:\Users\John\Desktop\SimpleDLL\Sample.txt"); fileReadPerm.Assert(); string fileContent; FileStream file = new FileStream(@"C:\Users\John\Desktop\SimpleDLL\Sample.txt", FileMode.OpenOrCreate, FileAccess.Read); StreamReader sr = new StreamReader(file); fileContent = sr.ReadToEnd(); sr.Close(); file.Dispose(); return fileContent; } I tried running the report from Visual Studio using the Preview tab, by pressing F5, and by using Ctrl+F5. In each case I am getting #Error in my report (this is in the simple case of just reading text from a text file from the custom DLL). If I modify the function in the custom DLL to just return a string instead of read from a text file, it works. As an aside, do I need to restart the SQL Server or SQL Server Reporting Services services after making a change to a configuration file? Is there a straight-forward tutorial somewhere for creating custom DLLs for SSRS 2008, which need to access resources such as text files or WCF services (as opposed to tutorials for earlier versions of SQL Server)? When I do a search for a couple of generic terms on Google (e.g. http://www.google.com/search?hl=en&q=%22SSRS+2008%22+%22custom+dll%22), the first hit is this thread! The second result is another thread with a similar problem (but no answer there unfortunately) http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/394d7292-cbb0-4c0a-b698-11b785d03811/; in this case it seems as though they were able get their solution working in SSRS 2005 but not in SSRS 2008. This leads me to believe that such a tutorial might not yet exist. Alternatively is there some other way of calling a WCF service from an expression in an SSRS report? Even once this is working on my test machine, it is going to be a nightmare to deploy to various machines with different configurations, directory paths and so on.
April 26th, 2009 4:46pm

I am not sure if this will help but I have been trying to solve this problem at the moment as well and i have got it to work through the IDE but not on the report server yet.Two things I would have different to your example is that instead of having "Url="C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer\bin\SimpleDLL.dll"/>" in the codegroup i have "Url="file://C:/Program Files/Microsoft SQL Server/MSRS10.MSSQLSERVER/Reporting Services/ReportServer/bin/SimpleDLL.dll"". I saw this on one of the technet articles - can't remember which one sorry. Also I am not sure the codegroup is in the correct position. I think the end of your config file should have 3 closing codegroup tags before the closing policylevel tag.I am finding codegroupshard to work with. Hope you get a solution.
Free Windows Admin Tool Kit Click here and download it now
May 5th, 2009 4:54pm

Hi Robert, as you have said, BI Development Studio 2005 only enforces security policy settings if you run the stand-alone preview (Ctrl+F5), but not when running the built-in preview (F5). It works fine in the debug local mode and the debug mode but when i deploy it to the Local Server (LOcal HOst) it still throws an error (#Error)? Am i still missing something? Please let me know?
December 7th, 2010 2:54pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics