Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

How to use "Microsoft.SharePoint.dll" API in custom assembly of SSRS report

$
0
0

Hi,

Recently i had following requirement:-

  • Have to create a custom assembly (say MyAssembly.dll) for SSRS report (say MyReport.rdl)
  • Inside the code of "MyAssembly.dll" I have to use API of "Microsoft.SharePoint.dll" like creating SPSite, SPWeb etc object based on some sharepoint site url. Below is a method called "GetReportTitle"as shown below
  • namespace SSRS.ResourcesEx
    {publicstaticclass MyClass
        {publicstaticstring GetTitle()
            {string strTitle = string.Empty;try
                {
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {using (SPSite site = new SPSite("http://<ServerName>/Site/"))
                        {using (SPWeb web = site.OpenWeb())
                            {
                                 strTitle = web.Title;
                            }
                        }
                    });
    
                }
                catch (Exception ex)
                {
                    strTitle = ex.Message + "-----" + ex.StackTrace;
                }return strTitle;
            }
        }
    }
  • MyAssembly.dll is added to GAC so that it is fully trusted.
  • Also i have applied "[assembly: AllowPartiallyTrustedCallers()]" to MyAssembly.dll
  • Report"MyReport.rdl" have reference of MyAssembly.dll
  • Inside report MyReport.rdl i have a chart whose Title is based on a static method "GetReportTitle" that is present inMyAssembly.dll.
  • However when i try to access the report the chart title displays the error message for sharepoint security error as shown below
  • This is because i am using Sharepoint API in  GetReportTitle.If I comment code of sharepoint API in method then every thing works fine.
  • I think this error is related to code access security policy.
  • But i am depolying the custom assembly in GAC so that it is fully trusted.

Do i need to make any entry in "C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\rssrvpolicy.config" file of report server ?

Please help me if any body have any idea !

 


Deepak Kejriwal

Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>