I’m trying to automate running dotMemory.exe from commandline to analyze multiple processes.
I now run into an issue what sometimes occurs.
dotMemory.exe fails with a ““Unable to attach to the process #mynumber: Make sure it exists and it is a .NET Framework 4.0+/.NET Core 3.0+/.NET 5+ process.””
If I start a new PowerShell instance, it works fine, but the original PowerShell instance cannot be used anymore.
Command that I use: .dotMemory-2024.1.1.exe --log-level=trace attach 14768
(14768 is the PID)
I also tried it in a powershell script but that resulted in the same issue.
$proc = New-Object System.Diagnostics.Process
$proc.StartInfo.FileName = "dotMemory-2024.1.1.exe"
$proc.StartInfo.Arguments = "--log-level=trace attach 14768"
$proc.StartInfo.UseShellExecute = $false
$proc.StartInfo.RedirectStandardInput = $true
$proc.Start()
What I found in %Temp%2JetLogsJetBrainsLog.JetBrains.2024-04-23T12-20-58.dotMemory-2024_1_1#14768.log
--- EXCEPTION #1/2 [FileLoadException]
Message = “Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)”
ExceptionPath = Root.InnerException
ClassName = System.IO.FileLoadException
HResult = FUSION_E_REF_DEF_MISMATCH=80131040
Source = System.Memory
FileLoad_FileName = “System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”
FileLoad_FusionLog = “
=== Pre-bind state information ===
LOG: DisplayName = System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Users/someuser/AppData/Local/Temp/2/JetBrains/dotMemory.exe/Qudorinirexidelu
LOG: Initial PrivatePath = NULL
Calling assembly : System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:WindowsMicrosoft.NETFramework64v4.0.30319configmachine.config.
LOG: Post-policy reference: System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/Users/someuser/AppData/Local/Temp/2/JetBrains/dotMemory.exe/Qudorinirexidelu/System.Runtime.CompilerServices.Unsafe.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
What I see in the log is the ‘Framework64v4.0.30319’. I know dotMemory requires 4.7.2. Is it somehow using a wrong .NET version?