asp.net-coredllweb-deploymentfilenotfoundexceptionjsreport

JSReport: ASP.net Core Deployment - Could not load file or assembly jsreport.Local


I am using ASP.net Core 3.0 and I wanted to have html to pdf export functionality, I found JSReport as a solution So I followed the Jon Blaha's Implementation of JSReport .net SDK to export html to pdf, I have successfully install nugets jsReport.Binary, jsReport.Local and jsReport.AspNetCore in my development machine. Following are the dlls that got installed

I have followed the Jon Blaha's implementation and Export html to pdf working fine on my dev machine. But when I uploaded dlls with my project's published dll my application got stopped working

an error occurred while starting the application

I searched for this error and I found that I had to enable logging through my web.config by using

stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout"

to get the actual error message behind my startup failure.

After doing the required changes to my web.config and I got the log file generated, it says

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.

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)

I doubled check my wwwroot directory through FTP using FileZilla and I had all these required jsReport dlls on my server but still I am getting file not found.

I even compared the dll versions and made sure my .csproj file reference all the required jsreport dlls but still its unable to find jsReport.Local.dll.

I have jsReport.Local.dll in my dev machine and also in my server's wwwroot directory where all the other dlls are present including my project.dll and project.views.dll and project.exe etc.

My cs.proj file also has the following

<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>

Solution

  • As Suggested by Jan Blaha on Github issue.

    Please try to create just a hello world app. Does it work there? Please upload somewhere your project and how the deployment output looks like.

    I tried preparing a new asp.net core mvc 3 app. Referenced jsreport. Published to the folder and there is no issue when running the asp.net server through outputted exe.

    I created a new hello world app and referenced jsReport and published it and uploaded it to my subdomain for testing purpose. and I got couple of reasons for this to not work

    1. There was a file permission issue on my server
    2. jsReport tried to create a folder on the root directory called 'jsReport' that was not being created because of folder access rights (file permission issues)
    3. I was not uploading 2 of json files projectname.deps.json and projectname.runtimeconfig.json during my uploading process

    After doing the above changes to my main domain, the site finally got up working!