使用Microsoft ReportViewerControl v14 时是否需要加载SqlServerTypes?

6 c# asp.net reportviewer webforms reporting-services

在我通过 nuget 安装了报表查看器控件 v14 包后,在我的项目根目录中创建了一个文件夹“SqlServerTypes”。有一个 readme.htm 文件,它建议将一段 SqlServerTypes 加载代码添加到具有报表查看器控件的 Web 表单页面中。

但我发现即使没有这个 SqlServerTypes 加载代码,报表查看器仍然运行良好。

我想知道是否有必要添加这个加载代码。

谢谢。


************* readme.htm *************

加载本机程序集所需的操作 要将使用空间数据类型的应用程序部署到未安装“SQL Server 系统 CLR 类型”的计算机,您还需要部署本机程序集 SqlServerSpatial140.dll。此程序集的 x86(32 位)和 x64(64 位)版本都已添加到项目的 SqlServerTypes\x86 和 SqlServerTypes\x64 子目录下。如果未安装 C++ 运行时,还包括本机程序集 msvcr120.dll。

您需要添加代码以在运行时加载正确的程序集之一(取决于当前架构)。

ASP.NET 网站对于 ASP.NET 网站,将以下代码块添加到添加了报表查看器控件的 Web 窗体的代码隐藏文件中:

默认.aspx.cs:

public partial class _Default : System.Web.UI.Page
{
        static bool _isSqlTypesLoaded = false;

    public _Default()
    {
        if (!_isSqlTypesLoaded)
        {
            SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~"));
            _isSqlTypesLoaded = true;
        }

    }
    }
Run Code Online (Sandbox Code Playgroud)

**** SqlServerTypes 文件夹 *****

[SqlServerTypes]
Loader.cs 
readme.htm

[SqlServerTypes\x64]
msvcr120.dll
SqlServerSpatial140.dll

[SqlServerTypes\x86]
msvcr120.dll
SqlServerSpatial140.dll
Run Code Online (Sandbox Code Playgroud)

******** Nuget 包 ********

https://www.nuget.org/packages/Microsoft.ReportingServices.ReportViewerControl.WebForms

安装包 Microsoft.ReportingServices.ReportViewerControl.WebForms -Version 140.1000.523