Case by Case..

Wang Ting's Tech Blog
随笔 - 40, 评论 - 249, 引用 - 12

导航

工具

关于

勿发广告,谢谢配合

标签

每月存档

广告



访客

Useful Logging Options in .Net

System.Net and related.

Summary: Useful logging option to track problems on Sockets, Remoting Channel, Web Requests and HttpListener.

Platform: .Net 2.0

Details:

How to: Configure Network Tracing
http://msdn2.microsoft.com/en-us/library/ty48b824.aspx

Enabling Network Tracing
http://msdn2.microsoft.com/en-us/library/a6sbz1dx.aspx


ADO.Net Managed Provider ETW Tracing

Summary: Very powerful tracing with details on API invocations, 1st chance exceptions. Next generation of high performance tracing.

Platform: .Net 2.0 with Windows 2003 SP1 or Windows XP SP2

Details:

Tracing Data Access
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/tracingdataaccess.asp


System.Xml Serialization.

Summary: Leave the temporary auto-generarted XML serialization code behind for easier debugging XML serialization problems.

Platform: .Net 1.0 above

Details:

PRB: You Receive a "System.IO.FileNotFoundException" Error When the Client Application Calls a Web Service
http://support.microsoft.com/?id=823196

Troubleshooting Common Problems with the XmlSerializer
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp


Visual Studio 2005 IDE Activity Log

Summary: Provide additional information for IDE crash issues.

Platform: Visual Studio 2005

Details:

/Log (devenv.exe)
http://msdn2.microsoft.com/en-us/library/ms241272.aspx


VSTS related


Team Foundation Server Component Trace

Summary: File based trace for TFS components.

Platform: Team Foundation Server

Details:

Global Web.Config File Settings in Team Foundation Server Components
http://msdn2.microsoft.com/en-us/library/ms400784.aspx

Enabling Trace for Team Foundation Server Components
http://msdn2.microsoft.com/en-us/library/ms400788.aspx


Team Build Service Log

Summary: Detailed log for troubleshooting Team Build Service problems.

Platform: Team Foundation Server

Details:

Please refer to the comment in the following file where Team Build Service is installed:

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\tfsbuildservice.exe.config


Team Foundation Client Log

Summary: This log is useful for tracking problem, espcially performance problem with Team Explorer.

Platform: Team Foundation Server Client Components

Details:

There seems to be no formal document on this. Buck's blog has mentioned it:

How to measure performance using the web service performance dialog
http://blogs.msdn.com/buckh/archive/2006/09/25/performance_dialog.aspx

Apart from Buck's blog, the setting for the .Config file can also use a file based trace listener:

  <system.diagnostics>

    <switches>

      <add name="General" value="4" />

    </switches>

    <trace autoflush="true" indentsize="3">

      <listeners>

        <add name="myListener"

        type="Microsoft.TeamFoundation.TeamFoundationTextWriterTraceListener,Microsoft.TeamFoundation.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

        initializeData="c:\devenv.log" />

      </listeners>

    </trace>

  </system.diagnostics>

 


WinForm related


IEHost Log

Summary: Trace for troubleshooting .Net WinForm component download hosted in IE.

Platform: .Net 1.0 above

Details:

HOW TO: Use the IEHost Log to Debug .NET Object Hosting in Internet Explorer
http://support.microsoft.com/?id=313892


System.Transactions related


System.Transactions

Summary: Useful for tracing internal Transaction code paths..

Platform: .Net 2.0

Details:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <system.diagnostics>

    <switches>

      <add name="System.Transactions" value="Verbose"/>

    </switches>

    <sources>

      <source name="System.Transactions">

        <listeners>

          <add name="System.Transactions"/>

        </listeners>

      </source>

    </sources>

    <sharedListeners>

      <add name="System.Transactions" type="System.Diagnostics.XmlWriterTraceListener" initializeData="mylog.xml"/>

    </sharedListeners>

    <trace autoflush="true"/>

  </system.diagnostics>

</configuration>

 

 


posted on 2006-08-16 00:17:00 by TingWang  评论(6) 阅读(2901)

SOS 2.0中!StopOnException和ADPlus的结合使用

.Net Framework 2.0带的Managed Debugging Extension SOS.DLL中新增了一个StopOnException的命令。使用它,我们可以比较方便得在指定类型的Exception发生时抓到进程的内存镜像。这样就避免了使用"ADPlus -Crash -FullOnFirst"而导致生成大量无用的First Chance Exception的情况,步骤如下:

1. 创建一个ADPlus的配置文件StopOnException.cfg:

<ADPlus> <!-- Set ADPlus run options --> <Settings> <RunMode> CRASH </RunMode> <OutputDir> C:\Dumps </OutputDir> </Settings> <!-- Load sos.dll --> <PreCommands> <Cmd> .loadby sos.dll mscorwks </Cmd> </PreCommands> <!-- Create and configure our .NET exception breakpoint --> <Exceptions> <Config> <!-- Break on CLR exception type --> <Code> CLR </Code> <Actions1> Log;Stack </Actions1> <!-- Action to run if our manged exception is on the stack --> <CustomActions1> !StopOnException System.ArgumentException 1; .if (@$t1 == 1) {.dump /ma /u C:\Dumps\ArgException.dmp} </CustomActions1> <ReturnAction1> gn </ReturnAction1> <Actions2> Log;Stack;FullDump </Actions2> </Config> </Exceptions> </ADPlus>

上面的配置将在System.ArgumentException被扔出的时候抓内存镜像,生成在C:\Dumps。

2. 以下面的命令运行ADPlus,将Debugger attach到WindowsApplication1.exe上:

cscript adplus.vbs -c c:\StopOnException.cfg -quiet -pn WindowsApplication1.exe

!StopOnException还有一个-derived参数略有用,详细可参考帮助!help StopOnException

posted on 2006-08-11 17:45:00 by TingWang  评论(2) 阅读(5003)

Debugging Windows Service

关于调试Windows Service的启动问题,基本可以参考下面的文章的“Configure a service to start with the WinDbg debugger attached”节:

How to debug Windows services
http://support.microsoft.com/kb/824344/en-us

但是有一类Windows Service,必须要用域用户身份运行,如VSTS中的Team Build Service,它们不能使用SYSTEM身份运行,所以就无法与桌面交互(Interactive with Desktop)。这样一来文章中提到的做法就无法达到要求,因为启动的Debugger将不会出现在桌面上。要解决这个问题,可以使用下面的方法,假设我们要在Team Build Service启动后立刻加载Debugger:

1. 用GFlags给TFSBuildService.exe设置下面的DebuggerPath:

D:\Debuggers\cdb.exe -server tcp:port=6789 -cf "c:\script.txt"

其中c:\script.txt是脚本文件,可以用类似下面的一些命令:

sxe -c ".dump /ma /u c:\\clr.dmp;g" clr
g

最后的g命令可保证服务能在超时前被启动起来,这样可以避免设置ServicesPipeTimeout 带来的重启。

2. 当服务被启动以后,运行WinDBG连接到cdb.exe建立的Debugging Server:

windbg -remote tcp:port=6789,server=localhost

3. 结束以后可以用qq命令退出

如果有什么更好的想法的话请告知,谢谢。

 

posted on 2006-08-11 02:18:00 by TingWang  评论(2) 阅读(5003)

运行多个Windows Live Messenger实例的方法

1. 将msnmsgr.exe复制msnmsgr2.exe

2. 用WinDBG打开msnmsgr.exe。

3. 用bp命令设置如下断点:

bp kernel32!CreateEventA "j (poi(esp+10) != 0) 'da poi(esp+10)';'g'"

4. g命令,开始运行进程。

5. 断点会不断被hit,并打印出CreateEvent创建的Event名字。

6. 继续g,直到找到一个叫“MSNMSGR”的Event:

0:000> g
ModLoad: 75e60000 75e87000 C:\WINDOWS\system32\apphelp.dll
ModLoad: 4dc30000 4dc5e000 C:\WINDOWS\system32\msctfime.ime
ModLoad: 777b0000 77833000 C:\WINDOWS\system32\CLBCatQ.DLL
ModLoad: 77010000 770d6000 C:\WINDOWS\system32\COMRes.dll
ModLoad: 74540000 745d4000 C:\WINDOWS\system32\mlang.dll
ModLoad: 59300000 59499000 C:\Program Files\MSN Messenger\msgslang.dll
ModLoad: 5b200000 5b42c000 C:\Program Files\MSN Messenger\msgsres.dll
*** ERROR: Module load completed but symbols could not be loaded for msnmsgr.exe
004cb7cc "MSNMSGR"
eax=00000001 ebx=00000000 ecx=000015d3 edx=7ffb0000 esi=008ee290 edi=77e67a55
eip=77e58f0b esp=0006fe88 ebp=0006fec4 iopl=0 nv up ei pl zr na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
kernel32!CreateEventA:
77e58f0b 8bff mov edi,edi

7. 用db命令,打出地址附近的字节:

0:000> db 004cb7cc
004cb7cc 4d 53 4e 4d 53 47 52 00-00 00 00 00 2e 00 90 90 MSNMSGR.........
004cb7dc 2e 00 00 00 52 74 6c 4c-6f 67 4f 75 74 70 75 74 ....RtlLogOutput
004cb7ec 00 00 00 00 53 6f 66 74-77 61 72 65 5c 4d 69 63 ....Software\Mic
004cb7fc 72 6f 73 6f 66 74 5c 4d-53 4e 4d 65 73 73 65 6e rosoft\MSNMessen
004cb80c 67 65 72 00 41 70 70 53-65 74 74 69 6e 67 73 00 ger.AppSettings.
004cb81c e2 23 5c 27 47 37 d0 11-9f ea 00 aa 00 3f 86 46 .#\'G7.......?.F
004cb82c 64 c1 cf dc 38 2b d2 11-b7 ec 00 c0 4f 8f 5d 9a d...8+......O.].
004cb83c 64 00 6c 00 6c 00 00 00-00 00 00 00 04 00 00 00 d.l.l...........

8. 用UltraEditor打开msnmsgr2.exe,根据上面的字节找到文件资源中的字符串MSNMSGR。将其改为其它字符串,如MSNNSGR。保存msnmsgr2.exe

9. 运行msnmsgr2.exe打开Windows Live Messenger的第二个实例。

posted on 2006-08-10 18:13:00 by TingWang  评论(8) 阅读(5429)

Powered by: Joycode MVC Blogger System