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.

Screenshot in Windows Service

See original GitHub issue

Description

Taking a screenshot of a page only works while debugging inside Visual Studio, if I build my windows service I get stuck on this method.

Complete minimal example reproducing the issue

public async System.Threading.Tasks.Task Async(string url, string outPath)
{
    await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
    var browser = await Puppeteer.LaunchAsync(new LaunchOptions
    {
        Headless = true
    });
    var page = await browser.NewPageAsync();
    await page.GoToAsync(url);
    await page.SetViewportAsync(new ViewPortOptions
    {
        Width = 1366,
        Height = 768
    });
    await page.ScreenshotAsync(outPath);//The process hangs here
    await page.CloseAsync();
    await browser.CloseAsync();
}

Expected behavior:

I can take the screenshot

Actual behavior:

The process hangs in the ScreenshotAsync method

Versions

  • Puppeteer-Sharp v 1.13.0, I know 1.14.0 is out but I can’t update because I get this when trying to update: “Severity Code Description Project File Line Suppression State Error Failed to add reference. The package ‘Mono.Posix.NETStandard’ tried to add a framework reference to ‘Mono.Posix’ which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance. Error HRESULT E_FAIL has been returned from a call to a COM component.”
  • Targeting .NET Framework 4.7.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
heherockitcommented, Apr 18, 2019

@AzeExMachina I downgrade to 1.11 and it works now. Thanks a lot 😃

0reactions
luowenjia1996commented, Sep 6, 2019

its about how to break session0 in windowsService

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows Service for taking screenshots - dotnetspider.com
Steps : Go to Run -> Type Services.msc -> Find your service in the list of all the installed services -> Right click...
Read more >
c# - Screen capture using windows service
I'm creating windows service to capture screen(windows 7). ( i tried this using windows application and it works properly. ).
Read more >
Screen capture in windows desktop service
If you google "c# take screenshot windows service" you'll find various articles and examples from other people who have tried this kind of ......
Read more >
8 Easy Ways to Take Screenshots in Windows 10 and 11
Alt + Print Screen​​ To take a quick screenshot of the active window, use the keyboard shortcut Alt + PrtScn. This will snap...
Read more >
[C# Windows Service] Automatic Screen Capture
Open visual studio (I'm using VS2012), and then create new project. Select windows service template project, see picture above. Normally, you ...
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