Share via


Configuring Server Files in Visual Studio 2005 or 2008

Server Files refer to a collection of Report Web Services that expose reports on an IIS server. Server Files were originally provided as a Crystal Services node in Crystal Reports in Visual Studio .NET 2002, but the node has since been removed. Each later version of Crystal Reports continues to support Server Files in the SDK, with some configuration work required for each version.

The Server Files are generated from underlying report files, which are stored in the sample reports folder (or any other folder you may designate) on the file directory of the web server.

Configuring Server Files

To configure server files for Visual Studio 2005 or 2008, you must complete two steps. First, create the Report Web Service that exposes your reports. The second step is to alter the web.config file that corresponds to the new web service. In Visual Studio 2005, the configuration folder for Server Files that is found in Visual Studio .NET 2002 was deprecated in favor of adding a configuration entry to the web.config file.

You could add the configuration entry to the web.config file of each project, one at a time. However, it is recommended instead that you add this configuration entry to the web.config file that is located within the virtual directory that contains the Report Web Services.

To create the Report Web Services required for Server Files

  1. Start Visual Studio.

  2. From the File menu, select New, and then click Web Site.

  3. In the New Web Site dialog box, select the Visual C# from the Language list.

  4. From the Templates list, click ASP.NET Web Service

  5. In the Location field, replace the default project name with the name of your project.

    For the purposes of this example, we will save the project in C:\InetPub\wwwroot\ with the name CrystalReportsWebServices.

    C:\InetPub\wwwroot\CrystalReportsWebServices\
    
  6. Click OK.

  7. From the Debug menu, click Start Debugging.

    A dialog box appears and states that the Web.config file must be modified. Click the OK button to enable debugging.

  8. Once debugging is complete, return to the application.

  9. From the Solution Explorer, right-click Service.asmx, and then click Delete.

  10. In the Solution Explorer, expand the App_Code folder, right-click Service.cs, and then click Delete.

  11. In the Solution Explorer, right-click the project name that is in bold type, and then click Add New Item.

  12. In the Add New Item dialog box, do the following:

    1. From the Installed Templates field, select Web Service.
    2. In the Name field, enter ServerFileReportService.asmx.
    3. Uncheck Place code in separate file.
    4. Click Add.
  13. Replace the contents of the ServerFileReportService.asmx file with the following line:

    <%@ WebService language="C#"
    class="CrystalDecisions.Web.Services.ServerFileReportService" %>
    
  14. From the File menu, click Save All.

  15. In the Solution Explorer, right-click the project name that is in bold type, and then click Add New Item.

  16. In the Add New Item dialog box:

    1. From the Installed Templates field, select Web Service.
    2. In the Name field, enter ServerFileReportManager.asmx
    3. Uncheck Place code in separate file.
    4. Click Add.
  17. Replace the contents of the ServerFileReportManager.asmx file with the following line:

    <%@ WebService language="C#"
    class="CrystalDecisions.Web.Services.ServerFileReportManager" %>
    
  18. From the File menu, click Save All.

To add the Server Files configuration entry to the web.config file

  1. From Solution Explorer, open the Web.Config file.

  2. Replace the entire contents of the Web.Config file with the below XML.

    In the below example, change the value of the root directory to the directory in which you have stored your reports. For the purposes of this example, the file path is set to C:\program files\Microsoft Visual Studio 8\Crystal Reports\Samples\en\Reports\Feature Examples.

    <?xml version="1.0"?>
    
    <configuration
    xmlns="https://schemas.microsoft.com/.NetConfiguration/v2.0">
       <configSections>
          <sectionGroup name="crystalDecisions">
             <section name="serverFileReportManager"
    type="System.Configuration.NameValueSectionHandler, System,
    Version=1.0.3300.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089, Custom=null"/>
          </sectionGroup>
       </configSections>
    
       <crystalDecisions>
          <serverFileReportManager>
             <add key="rootDirectory" value="C:\program files\Microsoft Visual Studio 8\Crystal Reports\Samples\en\Reports\Feature Examples"/>
          </serverFileReportManager>
       </crystalDecisions>
       <appSettings/>
       <connectionStrings/>
    
       <system.web>
          <compilation debug="true">
             <assemblies>
                <add assembly="CrystalDecisions.Web,
    Version=10.2.3600.0, Culture=neutral,
    PublicKeyToken=692FBEA5521E1304"/>
             </assemblies>
          </compilation>
       </system.web>
    </configuration>
    

    Note

    You must enter the file directory path to your reports folder where you see PUT_FILE_DIRECTORY_PATH_TO_REPORTS_FOLDER_HERE. For the path to the reports folder, see Sample Reports' Directory.

  3. Save your changes to the web.config file.

  4. To verify that the viewers' virtual directory works, open a browser and enter the URL to the published Report Web Service.

    https://localhost/CrystalReportsWebServices/ServerFileReportService.asmx?wsdl
    

Legacy Server Files and the Viewers' Virtual Directory

In previous versions of Crystal Reports, Server Files were served out of IIS from a centralized web service, which is in the viewers' virtual directory. Each succeeding version of Crystal Reports creates an additional directory named "viewers' virtual directory" in IIS, which allows you to maintain multiple versions of Crystal Reports.

The additional "viewers' virtual directory" becomes a maintenance issue, if you have coded Server Files in a project with an earlier version of Crystal Reports, and you are now upgrading to a later version. In your code, the name of the "viewers' virtual directory" in the WebServiceURL property of each ServerFileReport instance must be changed to the current location of the Report Web Service to enable your ServerFileReport instances to work.

Note

To verify the names and paths for the "viewers' virtual directory" for each version, see Viewers' Virtual Directory.

To change the "viewers' virtual directory" in the WebServiceURL property of your ServerFileReport instances

  1. Locate each occurrence in your project where the WebServiceURL property of a ServerFilesReport instance is assigned.

  2. Compare the name of the viewers' virtual directory that is currently assigned in your code against the name of the viewers' virtual directory that is used in previous versions.

    See Viewers' Virtual Directory.

  3. Change the name of the viewers' virtual directory that is used in your highest installed version of Crystal Reports.

    If your highest installed version of Crystal Reports is Crystal Reports for Visual Studio 2005, enter the path to the Report Web Service that you created earlier in this tutorial.

  4. Recompile and verify that the reports load correctly.

See Also