playwright-dotnet icon indicating copy to clipboard operation
playwright-dotnet copied to clipboard

[BUG] Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0,

Open jkennerley opened this issue 3 years ago • 1 comments

Context:

  • Playwright Version: Microsoft.Playwright, 1.21.0
  • Operating System : Win 11
  • .NET version: 6.0.202
  • Browser: any of All, Chromium, Firefox, WebKit
  • Extra:
  • trying to automate WITH playwright WITH vs-code AND dot net interactive.

To replicate :-

  • install vs code
  • install dotnet interactive
  • start a new file as ipnyb
  • paste in the script below in, and run it ...

Code Snippet

Help us help you! Put down a short code snippet that illustrates your bug and that we can run and debug locally. For example:


// Microsoft.Playwright, 1.21.0
#r "nuget:Microsoft.Playwright" 
// Microsoft.Bcl.AsyncInterfaces, 6.0.0
#r "nuget:Microsoft.Bcl.AsyncInterfaces"

using Microsoft.Playwright;
using System.Threading.Tasks;

var playwright = await Playwright.CreateAsync();

var browserTypeLaunchOptions = new BrowserTypeLaunchOptions
{
    Headless = false,
    SlowMo = 50,
};

var browser = await playwright.Chromium.LaunchAsync(browserTypeLaunchOptions);

var page = await browser.NewPageAsync();

await page.GotoAsync("https://playwright.dev/dotnet");

await page.ScreenshotAsync(new PageScreenshotOptions { Path = "screenshot.png" });


Describe the bug

This results in

Error: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at Submission#11.<Initialize>()
   at Submission#11.<Factory>(Object[] submissionArray)
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)

jkennerley avatar Apr 17 '22 15:04 jkennerley

This doesn't aim to solve it, but just to let you know that you can unblock yourself for now by using version 1.19.1 like this:

#r "nuget: Microsoft.Playwright, 1.19.1"

using Microsoft.Playwright;
using System.Threading.Tasks;

var playwright = await Playwright.CreateAsync();

var browserTypeLaunchOptions = new BrowserTypeLaunchOptions
{
    Headless = false,
    SlowMo = 50,
};

var browser = await playwright.Chromium.LaunchAsync(browserTypeLaunchOptions);

var page = await browser.NewPageAsync();

await page.GotoAsync("https://playwright.dev/dotnet");

await page.ScreenshotAsync(new PageScreenshotOptions { Path = "screenshot.png" });

slang25 avatar Apr 17 '22 17:04 slang25