【问题标题】:how to use windbg find out SqlConnection.ConnectionString?如何使用windbg找出SqlConnection.ConnectionString?
【发布时间】:2009-11-28 02:34:59
【问题描述】:

我可以使用“!do”转储 SqlConnection 实例,但不知道如何找出它的 ConnectionString:

0:018> !do 2fa7730
Name: System.Data.SqlClient.SqlConnection
MethodTable: 000007fef4455968
EEClass: 000007fef42b6530
Size: 104(0x68) bytes
 (C:\Windows\assembly\GAC_64\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll)
Fields:
              MT    Field   Offset                 Type VT     Attr            Value Name
000007fef80ee580  400018a        8        System.Object  0 instance 0000000000000000 __identity
000007fef7558ff0  40008cc       10 ...ponentModel.ISite  0 instance 0000000000000000 site
000007fef75888d8  40008cd       18 ....EventHandlerList  0 instance 0000000000000000 events
000007fef80ee580  40008cb      210        System.Object  0   static 0000000002769b58 EventDisposed
000007fef4966d98  4000be5       20 ...hangeEventHandler  0 instance 0000000000000000 _stateChangeEventHandler
000007fef49789e0  400172c       28 ...t.SqlDebugContext  0 instance 0000000000000000 _sdc
000007fef80ede60  400172d       58       System.Boolean  1 instance                0 _AsycCommandInProgress
000007fef445c100  400172e       30 ...ent.SqlStatistics  0 instance 0000000000000000 _statistics
000007fef80ede60  400172f       59       System.Boolean  1 instance                0 _collectstats
000007fef80ede60  4001730       5a       System.Boolean  1 instance                0 _fireInfoMessageEventOnUserErrors
000007fef4459458  4001733       38 ...ConnectionOptions  0 instance 0000000002fa7798 _userConnectionOptions
000007fef4458b68  4001734       40 ...nnectionPoolGroup  0 instance 0000000002fa7b28 _poolGroup
000007fef44596a0  4001735       48 ...onnectionInternal  0 instance 0000000002fa9130 _innerConnection
000007fef80f5f00  4001736       50         System.Int32  1 instance                0 _closeCount
000007fef80f5f00  4001738       54         System.Int32  1 instance             8863 ObjectID
000007fef80ee580  400172b      f30        System.Object  0   static 00000000027885a8 EventInfoMessage
000007fef4458860  4001731      f38 ...ConnectionFactory  0   static 00000000027885c0 _connectionFactory
000007fef80f5658  4001732      f40 ...eAccessPermission  0   static 000000000278f910 ExecutePermission
000007fef80f5f00  4001737      9c0         System.Int32  1   static            16803 _objectTypeCount

【问题讨论】:

    标签: windbg sos


    【解决方案1】:

    试试visual studio 2008调试器,调试一个使用SqlConnection的程序;

    以您喜欢的方式查找 SqlConnection 实例(它可以是本地变量、实例字段或静态字段..)。

    在 Watch 窗口中查看。展开它是每个可展开的子节点,直到你找到你想要的(我记得它分别存储了服务器、数据库、用户 ID、密码等部分)。

    记录导航到这些字段的路径,然后使用 windbg 转到同一字段。

    【讨论】:

    • 谢谢。这提醒我使用Reflector查看数据,发现是_userConnectionOptions._usersConnectionString。
    猜你喜欢
    • 2013-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多