Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 662507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:23:10+00:00 2026-05-13T23:23:10+00:00

Title kinda says it all. The usual SOS command !bpmd doesn’t do a lot

  • 0

Title kinda says it all. The usual SOS command !bpmd doesn’t do a lot of good without a name.

Some ideas I had:

  • dump every method, then use !bpmd -md when you find the corresponding MethodDesc
    • not practical in real world usage, from what I can tell. Even if I wrote a macro to limit the dump to anonymous types/methods, there’s no obvious way to tell them apart.
  • use Reflector to dump the MSIL name
    • doesn’t help when dealing with dynamic assemblies and/or Reflection.Emit. Visual Studio’s inability to read local vars inside such scenarios is the whole reason I turned to Windbg in the first place…
  • set the breakpoint in VS, wait for it to hit, then change to Windbg using the noninvasive trick
    • attempting to detach from VS causes it to hang (along with the app). I think this is due to the fact that the managed debugger is a “soft” debugger via thread injection instead of a standard “hard” debugger. Or maybe it’s just a VS bug specific to Silverlight (would hardly be the first I’ve encountered).
  • set a breakpoint on some other location known to call into the anonymous method, then single-step your way in
    • my backup plan, though I’d rather not resort to it if this Q&A reveals a better way
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:23:10+00:00Added an answer on May 13, 2026 at 11:23 pm

    The anonymous method isn’t really anonymous. It just hides behind a compiler generated name.

    Consider this small example:

    Func<int, int> a = (x) => x + 1;
    
    Console.WriteLine(a.Invoke(1));
    

    To find the return value, we need to find the name of the method implementation. To do that we need to locate the MethodDesc of the surrounding method. In this example it is Main(), so:

    0:000> !name2ee * TestBench.Program.Main
    Module: 6db11000 (mscorlib.dll)
    --------------------------------------
    Module: 00162c5c (TestBench.exe)
    Token: 0x06000001
    MethodDesc: 00163010
    Name: TestBench.Program.Main()
    JITTED Code Address: 001e0070
    

    Via the MethodDesc we can dump the IL for Main()

    0:000> !dumpil 00163010
    ilAddr = 003f2068
    IL_0000: nop 
    IL_0001: ldstr "press enter"
    IL_0006: call System.Console::WriteLine     
    IL_000b: nop 
    IL_000c: call System.Console::ReadLine 
    IL_0011: pop 
    IL_0012: ldsfld TestBench.Program::CS$<>9__CachedAnonymousMethodDelegate1
    IL_0017: brtrue.s IL_002c
    IL_0019: ldnull 
    IL_001a: ldftn TestBench.Program::<Main>b__0
    IL_0020: newobj class [System.Core]System.Func`2<int32,int32>::.ctor 
    IL_0025: stsfld TestBench.Program::CS$<>9__CachedAnonymousMethodDelegate1
    IL_002a: br.s IL_002c
    IL_002c: ldsfld TestBench.Program::CS$<>9__CachedAnonymousMethodDelegate1
    IL_0031: stloc.0 
    IL_0032: ldloc.0 
    IL_0033: ldc.i4.1 
    IL_0034: callvirt class [System.Core]System.Func`2<int32,int32>::Invoke 
    IL_0039: call System.Console::WriteLine 
    IL_003e: nop 
    IL_003f: ret 
    

    Notice the funny looking names. They are the names of the generate delegate type and the actual method. The method is called <Main>b__0. Let’s look at the method:

    0:000> !name2ee * TestBench.Program.<Main>b__0
    Module: 6db11000 (mscorlib.dll)
    --------------------------------------
    Module: 00152c5c (TestBench.exe)
    Token: 0x06000003
    MethodDesc: 00153024
    Name: TestBench.Program.<Main>b__0(Int32)
    Not JITTED yet. Use !bpmd -md 00153024 to break on run. 
    

    There you have it. MethodDesc is 00153024 and as the comment say, you can use !bpmd to set the breakpoint using the MethodDesc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 366k
  • Answers 366k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Two dimensional numpy arrays are indexed using a[i,j] (not a[i][j]),… May 14, 2026 at 4:37 pm
  • Editorial Team
    Editorial Team added an answer To fix something, you first need to find out what's… May 14, 2026 at 4:37 pm
  • Editorial Team
    Editorial Team added an answer $('.main .a').live('click', function () { if (!$(this).hasClass('One')) { alert('first'); //2… May 14, 2026 at 4:37 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.