Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
PrimalBlaze
Starting Member
1 Post |
Posted - 2005-09-21 : 22:22:01
|
Hello there!Sorry it's a bit of a long one but the basic gist is that I'm having considerable trouble setting the right security settings for the Custom Renderer I've developed.There's some background here for you, but if you're short on time feel free to skip to "The problem" below! Thanks heaps for reading.The situation:Delightfully, users can choose to export a report to CSV format. This is fantastic, because my client needs RS output in a CSV file format so they can import it into an existing tool of theirs.The client likes to view this data by opening it in Excel before doing the import, to verify it is correct.However, Excel won't correctly open a file exported into CSV format from RS because the CSV file is created with Unicode encoding, as opposed to ASCII encoding.My solution:I spent some time doing research on modifying settings for the CSV renderer. It has a property called "Encoding" which can take the value "ASCII" if I want it to. Calling this from a URL is easy: simply append "&rc:Encoding=ASCII" to the QueryString. However, obviously I don't want the client to have to go to this level of technical ability to get their nice Excel-compatible CSV file, nor is setting up a separate page of links a viable alternative as it requires a higher level of technical competence from the user.So I decided to create a custom renderer. Initially I started to create one Implementing the IRenderingExtension Interface, and was going to custom-write all the code. However I soon discovered this was going to be a lengthy process, so I searched a little harder.I discovered the Microsoft.ReportingServices.CsvRendering.dll assembly, which contains the type "CsvReport". So my plan for my custom renderer was as follows: 1) Create an instance of CsvReport. 2) Set CsvReport's encoding to ASCII. 3) Render the CsvReport and return the result to the user.The code: Imports Microsoft.ReportingServices.Interfaces Imports Microsoft.ReportingServices.Rendering.CsvRenderer Imports System.Collections.Specialized Public Class Renderer Implements Microsoft.ReportingServices.ReportRendering.IRenderingExtension Private m_csvrendCSVRenderer As CsvReport Public Sub New() m_csvrendCSVRenderer = New CsvReport End Sub Public ReadOnly Property LocalizedName() As String Implements IExtension.LocalizedName Get Return "CSV (Excel compatible)" End Get End Property Public Sub SetConfiguration(ByVal configuration As String) Implements IExtension.SetConfiguration m_csvrendCSVRenderer.SetConfiguration(configuration) 'NB this will be changed to insist on Encoding=ASCII in the final version End Sub'etc... (Render, RenderStream, etc.) End ClassThe installation: I build this custom renderer, and add it to RSReportServer.config: <Extension Name="CSVEXCEL" Type="Test.TestRendering.Renderer,Test.TestRendering"/> I add the following security settings to rssrvpolicy.config: <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Name="Test_TestRendering_Strong_Name" Description="This code group grants code signed with the TestRendering strong name full trust."> <IMembershipCondition class="StrongNameMembershipCondition" version="1" PublicKeyBlob="<public key for Test.TestRendering here>" /> </CodeGroup> Later, I also added the same security settings above to rsmgrpolicy.config. Furthermore (running out of ideas because of the problem below) I've also used the mscorcfg.msc utility to configure the assembly .dll to have Full Trust.The problem: I get the SecurityException shown in full below occurring in my RS logfiles when it attempts to load my custom renderer into the Export dropdown. The SecurityException doesn't occur if I remove the line "m_csvrendCSVRenderer = New CsvReport" from my code - however my custom renderer is obviously useless without that line. The error suggests that the CsvReport type requires any caller to have FullTrust - however giving my code FullTrust both system-wide AND in RS (as above) doesn't seem to have had any benefit. Is there any other restriction that CsvReport could be placing to stop me from being able to access it with my code? aspnet_wp!extensionfactory!1270!09/21/2005-23:59:28:: e ERROR: Exception caught instantiating report server extension: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Security.SecurityException: Request for the permission of type System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed. at Test.TestRendering.Renderer..ctor() The state of the failed permission was: <IPermission class="System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PublicKeyBlob="0024000004800000940000000602000000240000525341310004000001000100272736AD6E5F9586BAC2D531EABC3ACC666C2F8EC879FA94F8F7B0327D2FF2ED523448F83C3D5C5DD2DFC7BC99C5286B2C125117BF5CBE242B9D41750732B2BDFFE649C6EFB8E5526D526FDD130095ECDB7BF210809C6CDAD8824FAA9AC0310AC3CBA2AA0523567B2DFA7FE250B30FACBD62D4EC99B94AC47C7D3B28F1F6E4C8"/> --- End of inner exception stack trace --- at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Reflection.Assembly.CreateInstance(String typeName) at Microsoft.ReportingServices.Diagnostics.ExtensionClassFactory.AssertAndCreate(Assembly assembly, String typeName) at Microsoft.ReportingServices.Diagnostics.ExtensionClassFactory.AssertAndCreate(Assembly assembly, String typeName) at Microsoft.ReportingServices.Diagnostics.ExtensionClassFactory.GetNewExtensionInstance(String extensionName, String extensionType). aspnet_wp!configmanager!1270!09/21/2005-23:59:28:: e ERROR: An error occurred trying to load the 'CUSTOM_RENDERER' renderer. Not adding it to the export list. Details: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ReportingServices.WebServer.ViewerToolbarArea.RenderRendererWidgets(HtmlTextWriter outputWriter)If anyone can shed any help upon what I can do to get around this issue, or any other way I can grant my code the Code Access Privileges to stop CsvReport hitting me with this SecurityException I'd really appreciate your help! I've also aired this question to the #sqlrs channel on irc.freenode.net:6667, which I've found to be an excellent resource for all RS developers, but to no avail at this stage.Thanks in advance for any assistance, hopefully I can return the favour soon :)-Geoff R G WilliamsPrimal Blaze Ltd. |
|
Richar
Starting Member
1 Post |
Posted - 2008-10-28 : 12:29:50
|
Hi, have you solved your problem?As far as i am concerned, i want to develop and implement a rendering extension complying the encoding schema CP1252Sincerely yoursFred |
|
|
bushfoot
Yak Posting Veteran
53 Posts |
Posted - 2009-03-09 : 12:58:28
|
I have built a rendering extension and I am trying to see it out of reporting services and not having any luck!I am getting error messages that my class does not implement IExtension, but if I reflect by dll it appears to implement IExtension?Any idea anyone? |
|
|
JulioDiaz
Starting Member
2 Posts |
Posted - 2009-09-18 : 11:05:29
|
quote: Originally posted by bushfoot I have built a rendering extension and I am trying to see it out of reporting services and not having any luck!I am getting error messages that my class does not implement IExtension, but if I reflect by dll it appears to implement IExtension?Any idea anyone?
Hi,I also built a redering extesnion and I'm getting same error you got 'report server extension does not implement IExtension'; were you able to find a solution for this?I'd appriatiate your help inmensively.Regards and thanks in advance,Julio Diaz |
|
|
|
|
|
|
|