Witam ponownie wszystkich. Wziąłem się za to i mam problem z właściwie uruchomieniem tego. Nie potrafię zrozumieć tego, czy mój serwer musi mieć zainstalowanego chroma (bo chyba pakiet próbuje znaleźć chrome.exe). Podczas uruchamiania tego kodu otrzymuję następujące błędy:
[Authorize]
[Route("GetReport")]
public async Task<IActionResult> GetReport(string DateFrom, string DateTo, string Machines)
{
var bfOptions = new BrowserFetcherOptions()
{
};
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
bfOptions.Path = Path.GetTempPath();
}
using var browserFetcher = new BrowserFetcher(bfOptions);
_logger.LogInformation("START ====================");
await browserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision);
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = true
});
using (var page = await browser.NewPageAsync())
{
await page.GoToAsync(Url.Action("Index", "ReportGenerator", new
{
DateFrom = DateFrom,
DateTo = DateTo,
Machines = Machines
}));
var watchDog = page.WaitForFunctionAsync("generatingCompleted == true");
await watchDog;
}
_logger.LogInformation("END ====================");
return Ok(JsonConvert.SerializeObject(new { success = true }));
}
Błąd łapię na tym poleceniu:
await browserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision);
Błędy:
App.Controllers.ReportGeneratorController: Information: START ====================
„iisexpress.exe” (CoreCLR: clrhost): załadowano „C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.21\System.IO.Compression.ZipFile.dll”.
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w PuppeteerSharp.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
Zgłoszony wyjątek: „System.IO.FileNotFoundException” w System.Private.CoreLib.dll
„iisexpress.exe” (CoreCLR: clrhost): załadowano „C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.21\System.Diagnostics.StackTrace.dll”.
„iisexpress.exe” (CoreCLR: clrhost): załadowano „C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.21\System.Reflection.Metadata.dll”.
„iisexpress.exe” (CoreCLR: clrhost): załadowano „C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.21\System.IO.MemoryMappedFiles.dll”.
„iisexpress.exe” (CoreCLR: clrhost): załadowano „C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.21\System.IO.Compression.dll”.
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware: Error: An unhandled exception has occurred while executing the request.
System.IO.FileNotFoundException: Failed to launch browser! path to executable does not exist
File name: 'C:\Users\user\Desktop\ZLECENIA\App\App\.local-chromium\Win64-970485\chrome-win\chrome.exe'
at PuppeteerSharp.Launcher.GetOrFetchBrowserExecutableAsync(LaunchOptions options) in C:\projects\puppeteer-sharp\lib\PuppeteerSharp\Launcher.cs:line 184
at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in C:\projects\puppeteer-sharp\lib\PuppeteerSharp\Launcher.cs:line 50
at App.Controllers.ReportGeneratorController.GetReport(String DateFrom, String DateTo, String Machines) in C:\Users\user\Desktop\ZLECENIA\App\App\Controllers\ReportGeneratorController.cs:line 146
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Nie wyobrażam sobie takiej sytuacji, że na serwerze instaluję chroma, na pewno coś źle rozumuję :D