July 25, 2007 at 5:09 pm
I created my first SSRS custom assembly by following the very clarifying article "Integrating .NET Code and SQL Server Reporting Services" by Rod Paddock (CoDe Magazine) as precise as possible: no problem, no sweat. A part of that custom assembly deals with reading data from a Northwind database. Nothing special, but very educational. Running a preview of a report in Visual Studio: everything works as expected. Then I deployed it locally on my PC to see the results in Report Manager, but no way: no data is read from my database. In my code I added several extra's to be sure that the custom assembly is really used. That's OK.
It is a problem that has been mentioned many times, but I cannot find the proper solution. "Everybody" mentions the SqlClientPermission plus oPerm.Assert() condition: seems to be OK, or asserts to modify the Microsoft .NET Framework 2.0 Configuration, but I feel very uncomfortable with Microsoft .NET Framework 2.0 Configuration: what must be changed (I modified the level of the Local Intranet Zone into Full Trust: didn't work). Larson (2006): does not use database access in his assembly example. Turley et.al. (2006): hardly mention custom assemblies. Googling (SqlClientPermission SqlConnection Error) and reading this site: I don't have the idea that I am in the correct direction. Any help is appreciated, Leendert.
Imports System.Security.Permissions
Imports System.Data.SqlClient
Public Shared Function GetCustomerOrderCount(ByVal CustomerID As String) As Integer
Dim oPerm As New SqlClientPermission(PermissionState.Unrestricted)
oPerm.Assert()
Dim blnSelect As Boolean
blnSelect = False ' Show dummy output.
blnSelect = True ' Show database output.
Dim nRetVal As Integer
Dim oConn As New System.Data.SqlClient.SqlConnection
oConn.ConnectionString = _
"Data Source=PCC4200\vSDM_SERVER2005;Initial Catalog=Northwind;Integrated Security=SSPI"
oConn.Open()
Dim oCmd As New System.Data.SqlClient.SqlCommand
oCmd.Connection = oConn
oCmd.CommandText = _
"Select count(*) From Orders Where CustomerID = @CustomerID"
oCmd.Parameters.AddWithValue("@CustomerID", CustomerID)
nRetVal = oCmd.ExecuteScalar()
oConn.Close()
Dim nTEST As Integer
nTEST = 11
If blnSelect Then
Return nRetVal
Else
Return nTEST
End If
End Function
From the rssrvpolicy.config file.
<!-- Added, according to Paddock (2007), p. 6/9, 070723 -->
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="CoDeMagSample"
Description="CoDe Magazine Sample. ">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\bin\CoDeReportingLibrary.dll"
/>
</CodeGroup>
June 28, 2011 at 7:43 am
Did you ever solve this? I'd be interested in the answer, since I have the same problem.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply