[Bug]: Running install script for MSTest/NUnit/XUnit throws `System.AccessViolationException` in Powershell inside Windows Terminal
Closed this issue · 2 comments
Version
1.49.0
Steps to reproduce
Execute the steps from website:
https://playwright.dev/dotnet/docs/intro
- Create project
dotnet new nunit -n PlaywrightTests
- Go to project directory
cd PlaywrightTests
- Add new NuGet package
dotnet add package Microsoft.Playwright.NUnit
- Build the project
dotnet build
Project file should look like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.Playwright.NUnit" Version="1.49.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>
<ItemGroup>
<Using Include="NUnit.Framework" />
</ItemGroup>
</Project>
- Try execute the PowerShell (inside Windows 11 Windows Terminal) script to load the library, You should see the error come up
Microsoft Windows [Version 10.0.22631.4460]
(c) Microsoft Corporation. All rights reserved.
C:\Users\contoso>cd C:\Users\contoso\Desktop\test play\PlaywrightTests
C:\Users\contoso\Desktop\test play\PlaywrightTests>dotnet build
Restore complete (0,2s)
PlaywrightTests succeeded (0,3s) → bin\Debug\net9.0\PlaywrightTests.dll
Build succeeded in 0,8s
Workload updates are available. Run `dotnet workload list` for more information.
C:\Users\contoso\Desktop\test play\PlaywrightTests>pwsh bin/Debug/net9.0/playwright.ps1 install
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at DynamicClass.CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, Int32)
C:\Users\contoso\Desktop\test play\PlaywrightTests>
When executing from Windows Terminal (Visual Studio 2022 Developer Console), the script loads correctly
$ .\playwright.ps1 install
Downloading Chromium 131.0.6778.33 (playwright build v1148) from https://playwright.azureedge.net/builds/chromium/1148/chromium-win64.zip
(node:24456) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
136.9 MiB [====================] 100% 0.0s
Expected behavior
Playwright dll should be loaded correctly
Actual behavior
Unable to load dll for PlayWright
Additional context
No response
Environment
- Operating System: Windows 11 22631
- CPU: x64
- Browser:
- Google Chrome 131.0.6778.86
- .NET Version (TFM):
Version: 9.0.100
Commit: 59db016f11
Workload version: 9.0.100-manifests.c6f19616
MSBuild version: 17.12.7+5b8665660
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.100\
What is your PowerShell version? pwsh --version
I tried on Windows 11 with PowerShell 7.4.6
but was not able to reproduce. Also Command Prompt
in the Terminal App was working for me.
I'll close it for now since we failed to reproduce. If it works in one Terminal but not the other, I'd try to compare the Terminal sessions. e.g. pwsh
version, environment variables (maybe NODE_OPTIONS
is set) etc. Also I saw that your folder has a space included, maybe removing the space makes it work - this would give us an indication of where the issue originates from. Feel free to post updates here which might help other users running into it.