Thursday, March 8, 2012

.NET Permissions Error in Reporting Services when not using a custom assembly (Smiley Faces Are

.NET Permissions Error in Reporting Services when not using a custom assembly:

I need help resolving a permissions error I’m taking in a SQL RS 2005 report.

I have a report that that is includes the following code fragment in Report Properties -> Code:

Function rtf2text(ByVal rtf As String) As String
Dim rtfcontrol As New System.Windows.Forms.RichTextBox
Try
rtfcontrol.Rtf = rtf
Return rtfcontrol.Text
Catch ex as Exception
Return ex.Message
End Try
End Function

I reference the .NET System.Windows.Forms DLL under Report Properties ->References -> References, Assembly Name (heading):

System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

I have a text box with the following expression:

=code.rtf2text(First(Fields!EndingQuoteComment.Value, "QuoteHeader"))

And I’ve verified, by removing the code.rtf2text command that is populated with the following:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Arial;}}\viewkind4\uc1\pard\b\i\f0\fs32 ** Ending Quote Comments **\par\b0\i0\f1\fs17\par}

When I run the preview in Visual Studio is correctly strips the RTF and displays just “** Ending Quote Comments **”.When I ‘RUN’ locally or deploy to a SQL RS 2005 Server and run the report I take the following error:

Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I’ve tried everything that I can think of on the server to make this work.

I finally put together a Win 2003 box with SQL 2005, IIS, and RS 2005 running on it in a virtual machine to be 100% sure I had a standard clean install and deployed the report and I’m getting the same error.

Below I’ve included a basic standalone RDL file that demonstrates my issue.I get the error referenced above when I deploy the RDL below.Any ideas or suggestions are greatly appreciated?

<?xml version="1.0" encoding="utf-8"?>

<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">

<BottomMargin>0.25in</BottomMargin>

<RightMargin>0.25in</RightMargin>

<PageWidth>7.75in</PageWidth>

<rdBig SmilerawGrid>true</rdBig SmilerawGrid>

<InteractiveWidth>7.75in</InteractiveWidth>

<rdTongue TiednapToGrid>true</rdTongue TiednapToGrid>

<Body>

<ReportItems>

<Textbox Name="textbox21">

<Left>0.25in</Left>

<Top>0.25in</Top>

<rdBig SmileefaultName>textbox21</rdBig SmileefaultName>

<Width>6.375in</Width>

<Style>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<FontSize>7.5pt</FontSize>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

<Height>1.375in</Height>

<Value>=code.rtf2text("{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Arial;}}\viewkind4\uc1\pard\b\i\f0\fs32 ** Ending Quote Comments **\par\b0\i0\f1\fs17\par} ")</Value>

</Textbox>

</ReportItems>

<Height>5.25in</Height>

</Body>

<rd:ReportID>8804486c-882f-493c-8dfb-b2f778a24b21</rd:ReportID>

<LeftMargin>0.25in</LeftMargin>

<CodeModules>

<CodeModule>System.Windows.Forms, Version=2.0.50727.42, Culture=neutral, PublicKeyToken=b77a5c561934e089</CodeModule>

</CodeModules>

<Code>Function rtf2text(ByVal rtf As String) As String

Dim rtfcontrol As New System.Windows.Forms.RichTextBox

Try

rtfcontrol.Rtf = rtf

Return rtfcontrol.Text

Catch ex as Exception

Return ex.Message

End Try

End Function </Code>

<Width>7.25in</Width>

<InteractiveHeight>10in</InteractiveHeight>

<Language>en-US</Language>

<TopMargin>0.25in</TopMargin>

<PageHeight>10in</PageHeight>

</Report>

Definitely a .NET code access issue. Not an expert on such things, but here's a couple thoughts...

First off, I'd try changing the SSRS account(s) to your developer/admin account, and then run it. If it works, you know it's not your code (and I don't think it is your code). Then try changing back to your service account, and add the service account to the admins group. If that fixes it, it's just a question of narrowing down what permission you need to add.

This is a another longshot, but perhaps since it's running as a service account, perhaps the system won't let it access UI resources? You might to "Allow service to interact with desktop", or poking around in some of the other server security settings.

Like I said, doubt I've provided any sort of final answer, but perhaps this might get you a bit closer.

Geof

No comments:

Post a Comment