Search code examples
c#visual-studioapientity-framework-corejsreport

JsReport using C# .NET core and Vs


I am trying to learn JsReport using c# and .NET core and visual studio. I have installed the required nuget packages (jsreport.binary and jsreport.Local). I am trying to replicate the code found Here. The problem is that I keep getting the following error.

***Severity Code    Description Project File    Line    Suppression State
Error   MSB3021 Unable to copy file "C:\Users\jmodiba\source\repos\js\js\obj\Debug\net6.0\apphost.exe" to "bin\Debug\net6.0\js.exe". Access to the path 'bin\Debug\net6.0\js.exe' is denied.    js  C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets   5097*** 

here is the code,

using jsreport.Binary;
using jsreport.Local;
using jsreport.Types;

var rs = new LocalReporting().UseBinary(JsReportBinary.GetBinary()).AsUtility().Create();

await rs.RenderAsync(new RenderRequest()
{
    Template = new Template()
    {
        Recipe = Recipe.ChromePdf,
        Engine = Engine.None,
        Content = "Hello from pdf"
    }
});

Solution

  • I managed to find the problem. My antivirus kept on moving the .exe file created to quarantine. Once I created an exception in the antivirus setting my code ran correctly.