Is it possible to mirror a running .NET process?

I have an application with dynamic types released at runtime. To test the generated .NET code, we save the dynamically generated assemblies and use Reflector.

I am wondering if there is a way to reflect them in the reflex path while the corresponding process is running without having to keep dynamic assemblies? In other words, you have a "Attach to Process ..." button in the reflector.

Thank.

EDIT: The only point of this function is to think about dynamically generated assemblies.

+2


source to share


2 answers


I know that you are probably looking for C # code that will come out of dynamic assemblies, and that this question is pretty old, however ...

You can get into IL of the current dynamic assembly using the Visual Studio Immediate window or using WinDbg . (You must use WinDbg if you are debugging a 64-bit process as Visual Studio is still a 32-bit product.)



  • Attach to process .
    • WinDbg: This needs to be done "non-invasively" if another process is already attached as a debugger. Hit F6 (or select "File -> Attach to Process") and select the "Non-invasive" option if VS is already attached.
    • Visual Studio: VS does this automatically when you select Start Debugging or press F5, but you can do it manually by choosing Attach to Process from the Debug menu.
  • Load the SOS.dll file using the command !load SOS.dll

    or simply !load SOS

    .
    • WinDbg: In non-invasive mode, WinDbg needs the full path to SOS.dll. For .NET 4, the path is likeC:\Windows\Microsoft.NET\Framework64\v4.0.30319\SOS.dll

  • Abort and saline the stream.
    You can do this automatically in any debugger by setting a breakpoint or in VS by specifying an exception helper.
    • WinDbg: In non-invasive mode, you will need to manually select the stream using command ~

      and command ~n s

      . Use ~

      to view all streams and use command ~n s

      to switch. For example, use ~12 s

      12 to switch to stream number.
  • Get a stack trace along with command pointers. Command:!clrstack

  • Take the IP address and find the method that indicates. Command:!ip2md [address]

    • For example, if the IP for the method you want to reset is 0123456

      , you must issue the command !ip2md 0123456

      .
  • Dump IL for the method. Command:!dumpil [method descriptor]

    • For example, if the IP2MD command says "0A1B2C3D as the address of the method descriptor, you would issue the command

      ! Dumpil 0A1B2C3D".

This should allow you to see a dynamic assembly while in IL assembly.

+2


source


There is a working build add-in for Reflector ( http://weblogs.asp.net/kdente/articles/438539.aspx ). However, I suspect that it just helps in fetching paths to run assemblies, and assemblies loaded from disk using Reflector. However, it is probably worth a try. Also, creating reflector add-ins is not that difficult, so you can extend the add-in's runtime to automatically save the assembly to disk so that it can be loaded by Reflector (assuming the existing add-in doesn't.)



-1


source







All Articles