Custom Report Item Sample


New: 5 December 2005
PolygonsCRI is a simple custom report item sample. This sample uses the System.Component classes from the Microsoft .NET Framework and classes from the Microsoft.ReportDesigner and Microsoft.ReportingServices namespaces to implement a custom report item run-time component and design-time component that can be used in Report Builder.
The SQL Server samples are not installed automatically during setup. For instructions about how to install the samples, see Installing Samples.

Important:
Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications and assemblies should not be connected to or used with your production SQL Server database or your report server without the permission of the system administrator.



Requirements

You should be familiar with Visual Studio and Microsoft Visual C#, and your system must meet the following requirements to use the PolygonsCRI sample:
  • Microsoft SQL Server 2005 with Reporting Services
  • Microsoft SQL Server Business Intelligence Development Studio.
  • Microsoft Visual Studio 2005.
  • Microsoft .NET Framework version 2.0.
  • Reporting Services samples. A report server that you have permission to access on your network. Note: Business Intelligence (BI) Development Studio and Visual Studio 2005 are not supported on Itanium-based computers. However, support is available for x64-based computers. If the SQL Server 2005 sample databases have been deployed on an Itanium-based computer, use BI Development Studio or Visual Studio on either an x86-based or x64-based computer to modify and run the samples.

Location

This sample is located in the \Extension Samples\CustomReportItem Sample subdirectory of the Reporting Services samples directory.
For example:
C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Extension Samples\CustomReportItem Sample

Building the Sample

If you have not already created a strong name key file, generate the key file using the following instructions.
To generate a strong name key file
  1. Open a Microsoft Visual Studio 2005 command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.-- or --Open a Microsoft .NET Framework command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.
  2. Use the change directory command (CD) to change the current directory of the command prompt window to the folder where the samples are installed. Note: To determine the folder where samples are located, click the Start* button, point to All Programs, point to Microsoft SQL Server 2005, point to Documentation and Tutorials, and then click Samples Directory. If the default installation location was used, the samples are located in <system_drive>:\Program Files\Microsoft SQL Server\90\Samples.*
  3. At the command prompt, run the following command to generate the key file: sn -k SampleKey.snk Important: For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.
To build the PolygonsCRI sample
  1. Open the PolygonsCRI.sln project file into Visual Studio 2005.
  2. From the Build menu, select Build Solution
  3. Open the PolygonsCRI.sln project file in Visual Studio.

Deploying the Sample

To deploy the PolygonsCRI sample
  1. Edit rsreportserver.config to register the PolygonsCRI:
  2. Insert the following lines before </Extensions>: * <ReportItems>
    <ReportItem Name="Polygons" Type="Microsoft.Samples.ReportingServices.PolygonsCCustomReportItem,PolygonsCRI"/>
    </ReportItems> *
    1. Edit the rssrvpolicy.config file to add a code group for the custom report item:
    2. Add the following lines: * <CodeGroup
      class="UnionCodeGroup"
      version="1"
      PermissionSetName="FullTrust"
      Description="This code group grants PolygonsCRI.dll FullTrust permission. ">
      <IMembershipCondition
      class="UrlMembershipCondition"
      version="1"
      Url="C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\bin\PolygonsCRI.dll" />
      </CodeGroup> *
      1. Edit the rsreportdesigner.config file to register the run-time component, the design-time component, and the item type converter:
      2. Add the following lines before </Extensions>: * <ReportItems>
        <ReportItem Name="Polygons" Type="Microsoft.Samples.ReportingServices.PolygonsCCustomReportItem,PolygonsCRI"/>
        </ReportItems>
        <ReportItemDesigner>
        <ReportItem Name="Polygons" Type=" Microsoft.Samples.ReportingServices.PolygonsDesigner, PolygonsDesigner" />
        </ReportItemDesigner>
        <ReportItemConverter>
        <Converter Source="Chart" Target="Polygons" Type=" Microsoft.Samples.ReportingServices.PolygonsConverter, PolygonsDesigner" />
        </ReportItemConverter> *
        1. Copy the PolygonsCRI.dll file from the \PolygonCRI\Bin\Debug directory where you copied the sample project to the Visual Studio private assemblies directory (by default, \Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies).
        2. Copy the PolygonsCRI.dll file from the \PolygonCRI \Bin\Debug directory where you copied the sample project to the Microsoft SQL Server Reporting Services bin directory (by default, \Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\Bin).
        3. Copy the PolygonsDesigner.dll file from the \PolygonDesigner\Bin\Debug directory to the Visual Studio private assemblies directory (by default, \Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies).

        Running the Sample

        This section contains a quick walkthrough that shows how to reference the Polygon custom report item in Visual Studio and then test it.
        To add PolygonDesigner to the Visual Studio toolbox
        1. Right-click in the Visual Studio toolbox.
        2. Select Choose items.
        3. Navigate to the \Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies folder and select PolygonsDesigner.dll.
        To run the sample
        1. Open the \PolygonsReport\Polygons.sln sample report project in Visual Studio.
        2. Click on the Preview tab in the sample report, or deploy the sample report to the server and run the sample report.To edit a report using the PolygonDesigner custom control in Visual Studio, you can do any of the following:
        • Set the properties of the polygons control in the property browser.
        • Edit properties via the control's context menu.
        • Drag fields onto the drop areas of the control from the fields list.
        • Select the chart and in the context menu choose Convert to Polygons. © 2007 Microsoft Corporation. All rights reserved.

Last edited Nov 6, 2008 at 10:06 PM by bonniefe, version 17

Comments

webdevtn Feb 19, 2009 at 9:10 PM 
Here's the updated version:
http://www.codeplex.com/MSFTRSProdSamples/Release/ProjectReleases.aspx?ReleaseId=18649

omhoge Jan 4, 2008 at 8:45 PM 
Won't work in real life...
We've been unable to use this example to build a CRI.

The designer file requires Microsoft.ReportDesigner.CustomReportItemDesigner
but the version in Visual Studio-8 and VS-9 of Microsoft.ReportDesigner.dll does not include that class.

It would be great to know where he got the version of the dll he used since it seems to be required.

much appreciated

mikeythecomic Dec 17, 2007 at 3:41 AM 
I used the following in my Dataset to get it to draw something:

SELECT 0, 15 as x, 10 as y
UNION
SELECT 1, 90 as x, 10 as y
UNION
SELECT 2, 90 as x, 80 as y
UNION
SELECT 3, 10 as x, 90 as y


After looking in the code I noticed that the window it was drawing in was 100 x 100 starting at (0,0).