0

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.

XouDo
  • 945
  • 10
  • 19
  • 1
    Does this answer your question? [Attempted to read or write protected memory. This is often an indication that other memory is corrupt](https://stackoverflow.com/questions/4074585/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-ot) – possum May 01 '23 at 17:54
  • @possum Yeah, I've tried almost every solution on that page. This doesn't seem to be a code issue, as it works on one machine, but fails on another. It's related to the differences between the machine, and I'm trying to understand where else I should look. – new_user_2023 May 01 '23 at 17:58
  • Memory corruption is almost certainly a code issue assuming you're building the projects identically as per the first post and the hardware is good. – possum May 01 '23 at 20:41
  • Do you have anything happening in parallel? Are you calling external dlls? etc etc – gilliduck May 04 '23 at 14:07

0 Answers0