【问题标题】:PuppeteerSharp: Failed to launch ChromiumPuppeteerSharp:无法启动 Chromium
【发布时间】:2021-03-11 17:11:11
【问题描述】:

将 google chrome 更新到最新版本后开始出现错误:89.0.4389.82 (Official Build) (64-bit)。 操作系统:Windows 10

错误:

PuppeteerSharp.ChromiumProcessException: 
Failed to launch Chromium! [0309/160320.924:ERROR:os_crypt_win.cc(70)] Failed to encrypt: The system cannot find the file specified. (0x2)

请帮忙!

【问题讨论】:

  • 修复了使用 Chromium 而不是 Chrome
  • 请解释你做了什么来修复它。你如何“使用 Chromium 而不是 Chrome”。我以为 PuppeteerSharp 已经在使用 Chromium 了。
  • 可以指定'Chromium'或'Chrome'的可执行路径``` var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true, ExecutablePath = chromiumExecPath }); ```
  • 谢谢!是的,ExecutablePath 就是答案。我以为我不需要指定它,因为我使用的是 BrowserFetcher.DownloadAsync("851527")。但我需要 ExecutablePath,因为我指定了要下载的特定版本(不是默认版本),它会转到一个单独的目录。

标签: puppeteer puppeteer-sharp


【解决方案1】:

在使用应用程序在服务器中启动 chrome 时,我也遇到了同样的错误。我确实手动升级了谷歌浏览器,一切正常。

【讨论】:

    【解决方案2】:

    在尝试在生产服务器环境(Azure VM 中的 Windows Server 2019)中运行的 asp.net 应用程序中运行该应用程序后,我想详细说明 vidya 的回答“手动升级 google chrome”:

    根据此 URL 上的最新版本手动设置版本号: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/

    在我的情况下,版本是 890410。将您的代码设置为使用此版本而不是 DefaultChromiumRevision

    const string ChromiumRevision = "890410";
    var options = new BrowserFetcherOptions();
    options.Path = HttpContext.Current.Server.MapPath("/App_Data");
    var bf = new BrowserFetcher(options);
    await bf.DownloadAsync(ChromiumRevision);   
    string exePath = bf.GetExecutablePath(ChromiumRevision); 
    var browser = await Puppeteer.LaunchAsync(new LaunchOptions
    {
       Headless = true,
       ExecutablePath = exePath,
       Args = new string[]{"--disable-gpu","--no-sandbox"}
    }); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-19
      • 1970-01-01
      • 2022-12-18
      • 1970-01-01
      • 1970-01-01
      • 2021-03-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多