System.IO.FileNotFoundException System.Text.Json at Microsoft.Playwright.Transport.Connection
On my development machine this works perfectly. When I deploy my solution to a target machine (via InstallShield Msi) , it fails with:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=6.0.0.0, Culture=neutral The system cannot find the file specified.File name: 'System.Text.Json at Microsoft.Playwright.Transport.Connection..ctor at Microsoft.Playwright.Playwright.
I confirmed that System.Text.Json.dll is in the same directory as Microsoft.Playwright.dll
I have compared the files on my target machine with those in Bin on my dev machine. Even gone as far as straight copying everything from bin on the dev machine to the target - same issue.
I did have to manually add all of the node js stuff that the Nuget package installs on the dev machine but doesn't get recognized as locally copied files by Installshield.
Perhaps there is some path somewhere in all that stuff I need to set?
My solution targets .Net Framework 4.7.2, x86 I am connecting to an instance of Microsoft WebView2, hosted in winforms form.
The error originates from CreateAsync
Code Snippet private async void InitPlaywright() { playwright = await Playwright.CreateAsync(); browser = await playwright.Chromium.ConnectOverCDPAsync("http://localhost:" + CDPport); context = browser.Contexts[0]; page = context.Pages[0]; }
More details. Created a simple project (attached). When built as an exe where the form w/ webview and Playwright code is all in the same project, it works on the target machine. If I compile the form project as a dll and add a second winform project to reference the first project two issues happen.
- Problem #1842 - CreateAsync() has hard coded the path find playwright.cmd, and its getting the starting path from the project referencing it
- Working around that by moving .playwright directory, I then get the System.Text.JSON error again
This should be fixed in the latest version, please re-file if you still encounter issues.