I want to simply add a breakpoint to a line. I used the code "!mbp Program.cs 5" taking the answer of that thread. But after that it gives "Failed to load App Domain data for the shared AppDomain. Error = 0x80070057" error. Can anyone teach me what I'm doing wrong?
EDIT1: sosex is incompatible with .net 7 so it gives this error. After that I tried bpmd command. I added breakpoint to TestClass.Example() void. And Breakpoint works but after breakpoint execution it gives that " Access violation - code c0000005 (first chance) " error. What am I doing wrong about this?
EDIT2: bpmd(sos) is incompatible with .net7. So I downgraded to .net 6 and bpmd worked correctly. But I didnt understand one point. On .net7 project i can use bpmd for System.String.Contains method and its works correctly. System.String.Contains method is included in System.Private.CoreLib.dll. So how does this work correctly while my method (TestClass.Example()) gives an error? System.Private.CoreLib.dll is not builed with .net7 or is there another reason?
Code block.
namespace TestApp
{
class Program
{
private static void Main()
{
var testClass = new TestClass();
Console.ReadLine();
testClass.Example();
}
}
public class TestClass
{
public int X;
public void Example()
{
Console.WriteLine(X++);
}
}
}
WinDbg Output.
************* Preparing the environment for Debugger Extensions Gallery repositories **************
ExtensionRepository : Implicit
UseExperimentalFeatureForNugetShare : false
AllowNugetExeUpdate : false
- Configuring repositories
----> Repository : LocalInstalled, Enabled: true
----> Repository : UserExtensions, Enabled: true
************* Waiting for Debugger Extensions Gallery to Initialize **************
.
----> Repository : UserExtensions, Enabled: true, Packages count: 0
----> Repository : LocalInstalled, Enabled: true, Packages count: 36
Microsoft (R) Windows Debugger Version 10.0.25324.1001 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.
CommandLine: C:\Users\Loord\RiderProjects\TestApp\TestApp\bin\Debug\net7.0\TestApp.exe
************* Path validation summary **************
Response Time (ms) Location
Deferred srv*
Symbol search path is: srv*
Executable search path is:
ModLoad: 00007ff7`07660000 00007ff7`0768b000 apphost.exe
ModLoad: 00007ffe`a8870000 00007ffe`a8a65000 ntdll.dll
ModLoad: 00007ffe`a84f0000 00007ffe`a85ad000 C:\Windows\System32\KERNEL32.DLL
ModLoad: 00007ffe`a6430000 00007ffe`a66f8000 C:\Windows\System32\KERNELBASE.dll
ModLoad: 00007ffe`a85b0000 00007ffe`a8750000 C:\Windows\System32\USER32.dll
ModLoad: 00007ffe`a6170000 00007ffe`a6192000 C:\Windows\System32\win32u.dll
ModLoad: 00007ffe`a8010000 00007ffe`a803a000 C:\Windows\System32\GDI32.dll
ModLoad: 00007ffe`a6060000 00007ffe`a616b000 C:\Windows\System32\gdi32full.dll
ModLoad: 00007ffe`a6700000 00007ffe`a679d000 C:\Windows\System32\msvcp_win.dll
ModLoad: 00007ffe`a6330000 00007ffe`a6430000 C:\Windows\System32\ucrtbase.dll
ModLoad: 00007ffe`a7090000 00007ffe`a77d2000 C:\Windows\System32\SHELL32.dll
ModLoad: 00007ffe`a7e80000 00007ffe`a7f2c000 C:\Windows\System32\ADVAPI32.dll
ModLoad: 00007ffe`a6a60000 00007ffe`a6afe000 C:\Windows\System32\msvcrt.dll
ModLoad: 00007ffe`a8450000 00007ffe`a84eb000 C:\Windows\System32\sechost.dll
ModLoad: 00007ffe`a8040000 00007ffe`a816b000 C:\Windows\System32\RPCRT4.dll
(22d8.1680): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ffe`a8940670 cc int 3
0:000> g
ModLoad: 00007ffe`a8750000 00007ffe`a8780000 C:\Windows\System32\IMM32.DLL
ModLoad: 00007ffe`7e310000 00007ffe`7e371000 C:\Program Files\dotnet\host\fxr\7.0.4\hostfxr.dll
ModLoad: 00007ffe`7fd70000 00007ffe`7fdd3000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.4\hostpolicy.dll
ModLoad: 00007ffe`1e440000 00007ffe`1e939000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.4\coreclr.dll
ModLoad: 00007ffe`a8170000 00007ffe`a829a000 C:\Windows\System32\ole32.dll
ModLoad: 00007ffe`a79a0000 00007ffe`a7cf5000 C:\Windows\System32\combase.dll
ModLoad: 00007ffe`a68d0000 00007ffe`a699d000 C:\Windows\System32\OLEAUT32.dll
ModLoad: 00007ffe`a6850000 00007ffe`a68d0000 C:\Windows\System32\bcryptPrimitives.dll
(22d8.1680): Unknown exception - code 04242420 (first chance)
ModLoad: 00007ffe`1d920000 00007ffe`1e43a000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.4\System.Private.CoreLib.dll
ModLoad: 00007ffe`1d7a0000 00007ffe`1d91b000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.4\clrjit.dll
ModLoad: 00007ffe`a3f10000 00007ffe`a3f22000 C:\Windows\SYSTEM32\kernel.appcore.dll
ModLoad: 00000000`00420000 00000000`00428000 C:\Users\Loord\RiderProjects\TestApp\TestApp\bin\Debug\net7.0\TestApp.dll
ModLoad: 00000000`02270000 00000000`0227e000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.4\System.Runtime.dll
ntdll!NtMapViewOfSection+0x14:
00007ffe`a890d224 c3 ret
0:000> g
ModLoad: 00007ffe`7fd00000 00007ffe`7fd2a000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.4\System.Console.dll
ModLoad: 00007ffe`9cf90000 00007ffe`9cfa3000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.4\System.Threading.dll
ModLoad: 00000000`02290000 00000000`02298000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.4\System.Text.Encoding.Extensions.dll
ModLoad: 00007ffe`7e300000 00007ffe`7e30d000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.4\System.Runtime.InteropServices.dll
ntdll!NtMapViewOfSection+0x14:
00007ffe`a890d224 c3 ret
0:000> g
(22d8.3484): Break instruction exception - code 80000003 (first chance)
ntdll!DbgBreakPoint:
00007ffe`a8910810 cc int 3
0:008> !name2ee *!TestClass.Example
Module: 00007ffdbe8e4000
Assembly: System.Private.CoreLib.dll
--------------------------------------
Module: 00007ffdbeb6cf48
Assembly: TestApp.dll
Token: 0000000006000005
MethodDesc: 00007ffdbeb99bb0
Name: TestApp.TestClass.Example()
Not JITTED yet. Use !bpmd -md 00007FFDBEB99BB0 to break on run.
--------------------------------------
Module: 00007ffdbeb6ea80
Assembly: System.Runtime.dll
--------------------------------------
Module: 00007ffdbeb99ce8
Assembly: System.Console.dll
--------------------------------------
Module: 00007ffdbeb9b150
Assembly: System.Threading.dll
--------------------------------------
Module: 00007ffdbebc2020
Assembly: System.Text.Encoding.Extensions.dll
--------------------------------------
Module: 00007ffdbebc4f88
Assembly: System.Runtime.InteropServices.dll
0:008> !bpmd -md 00007FFDBEB99BB0
MethodDesc = 00007FFDBEB99BB0
Adding pending breakpoints...
0:008> g
(22d8.1680): CLR notification exception - code e0444143 (first chance)
JITTED TestApp!TestApp.TestClass.Example()
Setting breakpoint: bp 00007FFDBEAA0B90 [TestApp.TestClass.Example()]
Breakpoint 0 hit
TestApp!TestApp.TestClass.Example:
00007ffd`beaa0b90 55 push rbp
0:000> g
(22d8.1680): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
00007ffd`beaa0990 0000 add byte ptr [rax],al ds:00007ffd`beaa0990=00