Export (0) Print
Expand All

Printer Delivery Extension Sample

SQL Server 2005

Updated: 5 December 2005

The Printer Delivery Sample is a sample delivery extension that offers an introduction to Reporting Services delivery. The sample is a simple delivery extension for a printer. It uses the IMAGE rendering extension, along with the System.Drawing.Printing namespace in the Microsoft .NET Framework, to delivery a report to a printer. This sample is not supported on Itanium-based operating systems.

The SQL Server samples are not installed automatically during setup. For instructions about how to install the samples, see Installing Samples.

ms160778.note(en-US,SQL.90).gifImportant:
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.

You should be familiar with Visual Studio and Microsoft Visual C#, and your system must meet the following requirements to use the Printer Delivery sample:

  • Microsoft Visual Studio 2005.
  • Microsoft .NET Framework version 2.0.
  • The Reporting Services samples.
  • A report server that you have permission to access on your network, if you plan to use the sample extension to add additional data processing functionality to your server.

This sample is located in the Extension Samples\PrinterDelivery Sample subdirectory of the Reporting Services samples directory.

For example:

C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Extension Samples\PrinterDelivery Sample

Use the following steps to build the sample.

If you have not already created a strong name key file, generate the key file using the following instructions.

  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.
    ms160778.note(en-US,SQL.90).gifNote:
    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

    ms160778.note(en-US,SQL.90).gifImportant:
    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.

  1. Copy Microsoft.ReportingServices.Interfaces.dll from the report server \bin directory into your sample folder. By default, Microsoft.ReportingServices.Interfaces.dll is located in the \Reporting Services\ReportServer\bin subdirectory for the installed instance of Reporting Services. The exact path may vary on your installation of Reporting Services. For example:

    C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager\Bin
    
  2. Issue the following command to create the sample delivery extension Microsoft.Samples.ReportingServices.PrinterDeliverySample.dll.

    csc /t:library /out:Microsoft.Samples.ReportingServices.PrinterDeliverySample.dll *.cs /r:Microsoft.ReportingServices.Interfaces.dll
    

  1. Open the sample solution file (PrinterDeliveryCS.sln or PrinterDeliveryVB.sln) in Visual Studio.

  2. In Solution Explorer, select the PrinterDelivery project.

  3. On the Project menu, click Add Reference.

    The Add References dialog box opens.

  4. Click the .NET tab.

  5. Click Browse and find the Microsoft.ReportingServices.Interfaces.dll file on your local drive. By default, the assembly is located in C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\bin, then click OK.

    The selected reference is added to your project.

  6. On the Build menu, click Build Solution.

After you have completed the previous steps, Microsoft.Samples.ReportingServices.PrinterDeliverySample.dll can then be deployed to a report server and to Report Manager for use in delivering reports.

  1. Copy Microsoft.Samples.ReportingServices.PrinterDeliverySample.dll to the report server. The default location for report server extensions is C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\bin.

  2. In the RSReportServer.config file, make the following entry under the <Delivery> element.

    <Extension Name="Printer Delivery Sample" Type="Microsoft.Samples.ReportingServices.PrinterDelivery.PrinterDeliveryProvider,Microsoft.Samples.ReportingServices.PrinterDeliverySample">
       <Configuration>
          <Printers>
             <Printer>\\Server\MyNetworkPrinter1</Printer>
             <Printer>\\Server\MyNetworkPrinter2</Printer>
             <Printer>MyLocalPrinter</Printer>
          </Printers>
       </Configuration>
    </Extension>
    
    ms160778.note(en-US,SQL.90).gifNote:
    The <Printers> element is designed to enable a fixed set of printer names to be available for the delivery extension Printer setting. This list is ultimately checked against the known list of available printers on the report server to which the delivery extension is installed. If a selected printer does not match the known list of installed printers on the report server, the delivery fails with status, "The printer {0} is not currently installed on the server." If the Windows Service account used by the report server does not have permission to print to a printer installed in Windows, the printer will not be included in the list of available printers

  3. Copy the assembly to Report Manager. The default location for extensions for Report Manager is C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager\bin.

  4. In the RSWebApplication.config file, make the following entry under the <DeliveryUI> element:

    <Extension Name="Printer Delivery Sample" Type="Microsoft.Samples.ReportingServices.PrinterDelivery.PrinterDeliveryUIProvider,Microsoft.Samples.ReportingServices.PrinterDeliverySample"/>
    

For more information about deploying delivery extensions, see Deploying a Delivery Extension.

  1. Open the report server policy configuration file (rssrvpolicy.config). The default location for this file is C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer.

  2. Delivery extensions must be granted full trust. To do so, add the following code group information under the <CodeGroup … Zone="MyComputer" /> element:

    <CodeGroup class="UnionCodeGroup"
       version="1"
       PermissionSetName="FullTrust"
       Name="PrinterDeliveryCodeGroup"
       Description="Code group for my delivery extension">
          <IMembershipCondition class="UrlMembershipCondition"
             version="1"
             Url="C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\bin\Microsoft.Samples.ReportingServices.PrinterDeliverySample.dll"
           />
    </CodeGroup>
    
  3. If you are using the sample printer delivery extension in Report Manager, repeat steps 1 and 2 using the Report Manager policy configuration file (rsmgrpolicy.config) and the following code group:

    <CodeGroup class="UnionCodeGroup"
       version="1"
       PermissionSetName="FullTrust"
       Name="PrinterDeliveryCodeGroup"
       Description="Code group for my delivery extension">
          <IMembershipCondition class="UrlMembershipCondition"
             version="1"
             Url="C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager\bin\Microsoft.Samples.ReportingServices.PrinterDeliverySample.dll"
           />
    </CodeGroup>
    

    The default location for the rsmgrpolicy.config file is C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager.

  4. When you are finished deploying the sample, reset Microsoft Internet Information Services (IIS) using the reset tool Iisreset.exe, and then restart the Reporting Services Windows service.

    For more information regarding .NET security and Reporting Services, see Understanding Code Access Security in Reporting Services.

Release History

5 December 2005

Changed content:
  • Changed instructions for generating a key file, including the name and location of the key file.

Community Additions

ADD
Show:
© 2015 Microsoft