【问题标题】:JSReport: ASP.net Core Deployment - Could not load file or assembly jsreport.LocalJSReport:ASP.net Core 部署 - 无法加载文件或程序集 jsreport.Local
【发布时间】:2020-04-04 11:18:39
【问题描述】:

我正在使用 ASP.net Core 3.0 并且我想要 html to pdf 导出功能,我发现 JSReport 作为解决方案所以我按照 JSReport .net SDK 的 Jon Blaha's Implementation 将 html 导出为 pdf,我已经成功安装nugets jsReport.BinaryjsReport.LocaljsReport.AspNetCore 在我的开发机器中。 以下是已安装的 dll

  • jsReport.AspNetCore.dll (v2.0.2.0)
  • jsReport.Client.dll (v3.0.1.0)
  • jsReport.Local.dll (v2.2.2.0)
  • jsReport.Shared.dll (v2.1.0.0)
  • jsReport.Types.dll (v2.6.1.0)
  • jsReport.Binary.dll (v2.7.1.0)

我遵循了 Jon Blaha 的实现,Export html to pdf 在我的开发机器上运行良好。但是当我使用项目发布的 dll 上传 dll 时,我的应用程序停止工作

启动应用程序时发生错误

我搜索了这个错误,发现我必须通过我的web.config 使用

启用日志记录
stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout"

获取启动失败背后的实际错误消息。

对我的web.config 进行必要的更改后,我生成了日志文件,它说

System.IO.FileNotFoundException:无法加载文件或程序集“jsreport.Local,版本=2.2.2.0,文化=中性,PublicKeyToken=null”。系统找不到指定的文件。

crit: Microsoft.AspNetCore.Hosting.Diagnostics[6]
      Application startup exception
System.IO.FileNotFoundException: Could not load file or assembly 'jsreport.Local, Version=2.2.2.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'jsreport.Local, Version=2.2.2.0, Culture=neutral, PublicKeyToken=null'
   at Technicianspk.Startup.ConfigureServices(IServiceCollection services)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__2(IApplicationBuilder app)
   at Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter.<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)

我使用 FileZilla 通过 FTP 仔细检查了我的 wwwroot 目录,我的服务器上有所有这些必需的 jsReport dll,但我仍然找不到文件。

我什至比较了 dll 版本,并确保我的 .csproj 文件引用了所有必需的 jsreport dll,但仍然无法找到 jsReport.Local.dll

我的开发机器和服务器的 wwwroot 目录中有 jsReport.Local.dll,其中存在所有其他 dll,包括我的 project.dllproject.views.dllproject.exe 等。

我的cs.proj 文件也有以下内容

<ItemGroup>
 <PackageReference Include="jsreport.AspNetCore" Version="2.0.2" />
 <PackageReference Include="jsreport.Binary" Version="2.7.1" />
 <PackageReference Include="jsreport.Client" Version="3.0.1" />
 <PackageReference Include="jsreport.Local" Version="2.2.2" />
 <PackageReference Include="jsreport.Shared" Version="2.1.0" />
 <PackageReference Include="jsreport.Types" Version="2.6.1" />
</ItemGroup>

【问题讨论】:

    标签: asp.net-core dll web-deployment filenotfoundexception jsreport


    【解决方案1】:

    正如 Jan Blaha 在Github issue 上所建议的那样。

    请尝试只创建一个 hello world 应用。它在那里工作吗? 请上传您的项目以及部署输出的样子。

    我尝试准备一个新的 asp.net core mvc 3 应用程序。引用的jsreport。 发布到文件夹,运行asp.net时没有问题 服务器通过输出的exe。

    我创建了一个新的 hello world 应用程序并引用了 jsReport 并将其发布并上传到我的子域以进行测试。我有几个原因导致它不起作用

    1. 我的服务器上存在文件权限问题
    2. jsReport 尝试在根目录上创建一个名为“jsReport”的文件夹,但由于文件夹访问权限(文件权限问题)而未创建该文件夹
    3. 在上传过程中,我没有上传 2 个 json 文件 projectname.deps.jsonprojectname.runtimeconfig.json

    对我的主域进行上述更改后,网站终于可以正常工作了!

    【讨论】:

      【解决方案2】:

      我通过在Startup.cs 中使用此代码解决了我的问题

      services.AddJsReport(new LocalReporting()
                      .KillRunningJsReportProcesses()
                      .UseBinary(JsReportBinary.GetBinary())
                      .AsUtility()
                      .KeepAlive(false)
                      .Create()
                  );
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-15
        • 2013-11-07
        • 2016-08-09
        • 2014-04-11
        相关资源
        最近更新 更多