-2

How can I view executed SQL stored procedures from a memory crash dump of a C# .net application?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
DBK
  • 403
  • 4
  • 13
  • I dont understand the reason behind downvotes. The question is very clear and answer could be as simple as visual studio to a list of other tools . I was looking for something other than windbg and sos. I found a list of those tools: perfview, Window performance analyzer, xperf, etc – DBK Oct 14 '16 at 17:50
  • FYI: Asking for tools is off-topic. – Thomas Weller Nov 08 '16 at 10:53
  • If you hover over the down arrow next to your question, you'll see that one of the reasons for a down-vote is *"This question does not show any research effort"*. In other words, do some research *first*, then if you get stuck, come here with a more detailed, specific question. – Rufus L Aug 10 '17 at 00:08

2 Answers2

2

The information you want might not be available any more. The objects representing connections, queries and results may already have been garbage collected.

If you know the name of the class that is used for a query, you can use , load the extension and use the !dumpheap -type <classname> command to find those objects. Then use !do <address> to display the details of such an object. This might reveal the statement behind it.

If you're looking for a specific query, download the netext extension. It comes with the !wfrom command which allows you to select objects from the .NET heap based on criteria that you define.

TT.
  • 15,774
  • 6
  • 47
  • 88
Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
1

This question has no trivial answer and many experienced debuggers had to face this issue one way of another. Getting the information for a single SQL command is tedious, but straightforward. For many it is difficult. I was helping a colleague on a situation like this and put together this solution. It requires NetExt (download the zip file): https://github.com/rodneyviana/netext/tree/master/Binaries

0:067> !windex
Starting indexing at 14:18:54 PM
1000000 objects...
2000000 objects...
3000000 objects...
4000000 objects...
Indexing finished at 14:19:04 PM
399,314,598 Bytes in 4,049,972 Objects
Index took 00:00:10
0:067> .foreach ({$addr} {!wfrom -type *.sqlcommand -nospace -nofield where (_commandType == 4) select _parameters._items._items}) { r @$t1= {$addr} ;!wfrom -type *.sqlcommand -nofield -nospace where (_parameters._items._items==$dbgeval("@$t1")) "\n", _commandText," [",$addr(),"]\n========================"; !wfrom -nospace -nofield -array {$addr}  _parameterName,"=",$pp(_value) }

dbo.proc_getSiteIdOfHostHeaderSite [00000001011FCD90]
========================
@RETURN_VALUE=0n0
@HostHeader=sp.contoso.com
@RequestGuid={00000000-0000-0000-0000-000000000000}

proc_GetTpWebMetaDataAndListMetaData [0000000101D98DA0]
========================
@RETURN_VALUE=0n0
@WebSiteId={2815591d-55c8-4caf-842c-101d8807cb2a}
@WebId=NULL
@Url=
@ListId=NULL
@ViewId=NULL
@RunUrlToWebUrl=1
@DGCacheVersion=0n2
@SystemId=69 3a 30 29 2e 77 7c 73 2d 31 2d 35 2d 32 31 2d 31 33 38 35 31 37 34 39 39 32 2d 39 37 39 39 35  i:0).w|s-1-5-21-1385174992-97995 (...more...)
@MetadataFlags=0n18
@ThresholdScopeCount=0n5000
@CurrentFolderUrl=NULL
@RequestGuid={a00a0b30-1fcc-44d6-8346-ec20f8c49304}

proc_EnumLists [000000010236EDF0]
========================
@RETURN_VALUE=0n0
@WebId={a0a099b2-6023-4877-a7c1-378ec68df759}
@Collation=Latin1_General_CI_AS
@BaseType=NULL
@BaseType2=NULL
@BaseType3=NULL
@BaseType4=NULL
@ServerTemplate=NULL
@FMobileDefaultViewUrl=NULL
@FRootFolder=NULL
@ListFlags=0n-1
@FAclInfo=0n1
@Scopes=NULL
@FRecycleBinInfo=NULL
@UserId=NULL
@FGP=NULL
@RequestGuid={a00a0b30-1fcc-44d6-8346-ec20f8c49304}

(...)
Rodney Viana
  • 466
  • 2
  • 5