I have some XUnit tests that running perfectly on one machine, but keep failing on another. The error I get on the failure is:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Reflection.RuntimeAssembly.InternalLoad(System.Runtime.CompilerServices.ObjectHandleOnStack, System.Runtime.CompilerServices.ObjectHandleOnStack, System.Runtime.CompilerServices.StackCrawlMarkHandle, Boolean, System.Runtime.CompilerServices.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.Object, System.Object)
at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(System.Reflection.AssemblyName)
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()
I have already verified that the two machines are running the same .NET Framework (4.8) and the same .NET SDK (6.0.304). In addition, both machines are x64.
Is there anything else I should be on the lookout for to help debug this issue? I'm curious as to what's preventing the tests from running.