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, 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\100\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:

    • Insert the following lines before </Extensions>:

      <ReportItems>
         <ReportItem Name="Polygons" Type="Microsoft.Samples.ReportingServices.PolygonsCCustomReportItem,PolygonsCRI"/>
      </ReportItems>
      
  2. Edit the rssrvpolicy.config file to add a code group for the custom report item:

    • 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>
      
  3. Edit the rsreportdesigner.config file to register the run-time component, the design-time component, and the item type converter:

    • 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>
      
  4. 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).

  5. 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).

  6. 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.

See Also

Tasks

Compiling and Running Code Examples
SQL Server Reporting Services Samples

Other Resources

Getting Started with a Custom Report Item Implementation
Extension Samples (Reporting Services)

Help and Information

Getting SQL Server 2005 Assistance