我正在使用ASP.net Core3.0,我想拥有html to pdf导出功能,我找到了JSReport作为解决方案,所以我遵循Jon的实施 of JSReport .net SDK将html导出到pdf,我已经在我的开发机器上成功地安装了NUGETjsReport.Binary、jsReport.Local和jsReport.AspNetCore。下面是已安装的dll
我已经跟踪了Jon的实现和Export html to pdf在我的开发机器上的正常工作。但是当我用项目发布的dll上传dll时,我的应用程序就停止工作了
启动应用程序时出错。
我搜索这个错误,发现我必须通过我的web.config启用日志记录,方法是使用
stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout"获取启动失败后的实际错误消息。
在对我的web.config进行了必要的更改之后,我生成了日志文件,它说
System.IO.FileNotFoundException:无法加载文件或程序集'jsreport.Local,Version=2.2.2.0,Culture=neutral,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检查我的www.root目录,并且我的服务器上有所有这些必需的jsReport all,但是我仍然没有找到文件。
我甚至比较了dll版本,并确保我的.csproj文件引用了所有所需的jsreport,但仍然找不到jsReport.Local.dll。
我的开发机器中有jsReport.Local.dll,服务器的etc根目录中也有其他all,包括我的project.dll、project.views.dll和project.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>发布于 2020-04-05 14:20:35
正如Jan在Github问题上所建议的。
请尝试创建一个hello world应用程序。在那里有用吗?请上传您的项目和部署输出的样子。 我试着准备了一个新的asp.net核心mvc 3应用程序。参考jsreport。发布到文件夹中,并且在通过输出的exe运行asp.net服务器时没有问题。
我创建了一个新的hello应用程序,并引用了jsReport并发布了它,并将其上传到我的子域进行测试。我有几个理由让这件事行不通
projectname.deps.json和projectname.runtimeconfig.json。在对我的主域名做了上述修改后,网站终于开始工作了!
发布于 2021-09-22 21:22:18
我通过在Startup.cs中使用以下代码解决了我的问题
services.AddJsReport(new LocalReporting()
.KillRunningJsReportProcesses()
.UseBinary(JsReportBinary.GetBinary())
.AsUtility()
.KeepAlive(false)
.Create()
);https://stackoverflow.com/questions/61027283
复制相似问题