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.

dotnet test fails on sdk 6.0.200 - System.AccessViolationException

See original GitHub issue

Describe the bug

An exception is thrown when I run dotnet test, after updating to SDK version 6.0.200. It works perfectly with SDK versions 6.0.101 and 6.0.102.

The problem also happened with other unit test projects, not just the sample xUnit project.

To Reproduce

  • Install .NET SDK 6.0.200
  • mkdir TestTest
  • cd TestTest
  • dotnet new xunit
  • dotnet test

Further technical details

  • Include the output of dotnet --info
C:\Projetos\TestTest> dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.200
 Commit:    4c30de7899

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.200\

Host (useful for support):
  Version: 6.0.2
  Commit:  839cdfb0ec

.NET SDKs installed:
  6.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  • Exception thrown in console:
C:\Projetos> CD TestTest
C:\Projetos\TestTest> dotnet new xunit
The template "xUnit Test Project" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on C:\Projetos\TestTest\TestTest.csproj...
  Determining projects to restore...
  Restored C:\Projetos\TestTest\TestTest.csproj (in 1,27 sec).
Restore succeeded.

C:\Projetos\TestTest> dotnet test
  Determining projects to restore...
  All projects are up-to-date for restore.
  TestTest -> C:\Projetos\TestTest\bin\Debug\net6.0\TestTest.dll
Test run for C:\Projetos\TestTest\bin\Debug\net6.0\TestTest.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.1.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication t
hat other memory is corrupt.
   at System.Reflection.RuntimeAssembly.InternalLoad(System.Runtime.CompilerServices.ObjectHandleOnStack, System.Runtime
.CompilerServices.ObjectHandleOnStack, System.Runtime.CompilerServices.StackCrawlMarkHandle, Boolean, System.Runtime.Com
pilerServices.ObjectHandleOnStack, System.Runtime.CompilerServices.ObjectHandleOnStack)
   at System.Reflection.RuntimeAssembly.InternalLoad(System.Reflection.AssemblyName, System.Reflection.RuntimeAssembly,
System.Threading.StackCrawlMark ByRef, Boolean, System.Runtime.Loader.AssemblyLoadContext)
   at System.Reflection.Assembly.Load(System.Reflection.AssemblyName)
   at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginCache.CurrentDomainAssemblyResolve(System.
Object, Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.AssemblyResolveEventArgs)
   at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformAssemblyResolver.AssemblyResolverEvent(System.Obj
ect, System.Object)
   at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(System.Reflection.AssemblyNam
e)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(System.Reflection.AssemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr, System.Reflection.AssemblyName)
   at System.Reflection.RuntimeModule.GetTypes(System.Reflection.RuntimeModule)
   at System.Reflection.Assembly.GetTypes()
   at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginDiscoverer.GetTestExtensionsFromAssembly[[
System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Can
on, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Reflection.Assemb
ly, System.Collections.Generic.Dictionary`2<System.String,System.__Canon>)
   at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginDiscoverer.GetTestExtensionsFromFiles[[Sys
tem.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon,
 System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.String[], System.Col
lections.Generic.Dictionary`2<System.String,System.__Canon>)
   at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginDiscoverer.GetTestExtensionsInformation[[S
ystem.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Cano
n, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.Generi
c.IEnumerable`1<System.String>)
   at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginCache.GetTestExtensions[[System.__Canon, S
ystem.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Privat
e.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Collections.Generic.IEnumerable`1<
System.String>)
   at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginCache.DiscoverTestExtensions[[System.__Can
on, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.P
rivate.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.String)
   at Microsoft.VisualStudio.TestPlatform.Common.Hosting.TestRuntimeExtensionManager.Create(Microsoft.VisualStudio.TestP
latform.ObjectModel.Logging.IMessageLogger)
   at Microsoft.VisualStudio.TestPlatform.Common.Hosting.TestRuntimeProviderManager.get_Instance()
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestEngine..ctor()
   at Microsoft.VisualStudio.TestPlatform.Client.TestPlatform..ctor()
   at Microsoft.VisualStudio.TestPlatform.Client.TestPlatformFactory.GetTestPlatform()
   at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager..ctor()
   at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.get_Instance()
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.RunTestsArgumentProcessor+<>c.<get_Executor>b__6_0()
   at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7be
a7798e]].ViaFactory(System.Threading.LazyThreadSafetyMode)
   at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7be
a7798e]].ExecutionAndPublication(System.LazyHelper, Boolean)
   at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7be
a7798e]].CreateValue()
   at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7be
a7798e]].get_Value()
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.ArgumentProcessorFactory+<>c__DisplayClass20_0.<WrapLaz
yProcessorToInitializeOnInstantiation>b__0()
   at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7be
a7798e]].CreateValue()
   at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7be
a7798e]].get_Value()
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.GetArgumentProcessors(System.String[], System.Collections
.Generic.List`1<Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.IArgumentProcessor> ByRef)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.Execute(System.String[])
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Program.Main(System.String[])

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
TheRealAyCecommented, Mar 18, 2022

Could this be related to using Windows 7? Using 6.0.201 and having the exact same issue for a while now.

Fixed it by downgrading to 6.0.103 and using global.json to select the version.

2reactions
nesc58commented, Mar 8, 2022

Same issue here.

Uninstallation of dotnet version shows up a system error: api-ms-win-core-path-l1-0-0.dll is missing

I have also tried to install these dependencies: https://docs.microsoft.com/en-us/dotnet/core/install/windows?tabs=net60#additional-deps

But nothing solves the problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test fails in net6.0 with no info
So i started writing xunit test in net 6.0 with visual studio 2022 community preview. Everything was working fine on the first PC....
Read more >
Started to get "This project is targeting a version of .NET ...
I just checked with dotnet --info, the 3.1 runtime and SDK are already installed. Even after allowing VS to install the version it...
Read more >
Dotnet test error "Unrecognized command or argument" after ...
NET SDK 7.0.100) on the agent TeamCity for build . NET pojects, received a dotnet test run error. Tests fall with error:.
Read more >
Testing .NET Core Apps with Visual Studio Code
If they are equal everything will be fine and the test passes. Otherwise, the test fails and the message will be displayed. To...
Read more >
Microsoft.NET.Test.Sdk 17.7.1
Version Downloads Last updated 17.8.0‑preview‑23371‑04 9,418 18 days ago 17.7.1 130,840 5 days ago 17.7.0 642,735 17 days ago
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