question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Publish using "Produce single file" - Unhandled exception. System.ArgumentException: The path is empty. (Parameter 'path')

See original GitHub issue

Description

PuppeteerSharp 9.0.0 introduced a bug that will cause to fail the parameterless ctor of BrowserFetcher when using in some published exe with “Produce single file” enabled.

Complete minimal example reproducing the issue

  • Get any example code that uses the parameterless ctor of BrowserFetcher and put it into a console application (.net6 and .net7 are known to cause the issue)
  • Publish project with option “Produce single file” enabled.
  • Run the published exe
  • Minimal repro

Expected behavior:

Running without exception, like PuppeteerSharp 8.

Actual behavior:

Unhandled exception. System.ArgumentException: The path is empty. (Parameter 'path')
   at System.IO.Path.GetFullPath(String path)
   at System.IO.FileInfo..ctor(String originalPath, String fullPath, String fileName, Boolean isNormalized)
   at System.IO.FileInfo..ctor(String fileName)
   at PuppeteerSharp.BrowserFetcher.GetExecutablePath() in C:\projects\puppeteer-sharp\lib\PuppeteerSharp\BrowserFetcher.cs:line 354
   at PuppeteerSharp.BrowserFetcher..ctor() in C:\projects\puppeteer-sharp\lib\PuppeteerSharp\BrowserFetcher.cs:line 53
   at Program.<Main>$(String[] args) in C:\source\repos\PuppeteerSharpMinimalRepro\PuppeteerSharpMinimalRepro\Program.cs:line 5
   at Program.<Main>(String[] args)

Versions

  • Which version of PuppeteerSharp are you using? 9.0.0 and 9.0.1
  • Which .NET runtime and version are you targeting? .net6 and .net7

Additional Information - Workarround - Use overloads of the BrowserFetcher ctor.

var options = new BrowserFetcherOptions();
options.Path = Path.GetTempPath();
using var browserFetcher = new BrowserFetcher(options);
var revisionInfo = await browserFetcher.DownloadAsync();
await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true, ExecutablePath = revisionInfo.ExecutablePath });
await using var page = await browser.NewPageAsync();
await page.GoToAsync("http://www.google.com");
await page.ScreenshotAsync("google.jpg");

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
kblokcommented, Jan 23, 2023

Yeah. We should fix this.

0reactions
amaitlandcommented, Jan 27, 2023

See https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli#api-incompatibility for list of known APIs that are incompatible with SingleFile builds.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Paths.GetExecutablePath fails in .NET 6 single-file ...
Unhandled exception : System.ArgumentException: The path is empty. (Parameter 'path') at System.IO.Path.GetFullPath(String path) in System.
Read more >
XAF 21.2.3 System.ArgumentException: Empty path name ...
Location property returns an empty string in your case. This may be caused by the "Produce single file" publish option.
Read more >
Why is this producing an "Empty Path Name Is Not Legal" ...
1 Answer 1 ... The call stack of the exception shows that you are looking the completely wrong corner for this problem. You...
Read more >
C# System.ArgumentException: "Empty path name is not ...
Based on your findings in the debug. If FileName is blank, you will get this error. You need to input a filename. You...
Read more >
IL3000: Avoid accessing Assembly file path when ...
Cause. When publishing as a single-file (for example, by setting the PublishSingleFile property in a project to true), calling the Assembly.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found