怕忘记,重新记录一下。
有一种提高自己编程能力的好办法,就是看看.net framework的源码是如何写的?我们在追踪bug的时候,也往往需要追踪到.net framework的源码中去。按照如下方法设置vs2010,即可追踪到.net framwork的源代码中去。
可以看出,我将pdb文件放在了d:\msSource\MicrosoftPublicSymbols目录下面,这样在调试的时候,vs会自动去该目录下面找pdb文件。
我们可以看看这个目录下的文件
调试源码后,我们会找到一些平时不怎么写的东西。比如我追踪 IEnumerable<int>的扩展方法Sum,可以看到
如下的代码:
public static int Sum(this IEnumerable<int> source) {
if (source == null) throw Error.ArgumentNull("source");
int sum = 0;
checked {
foreach (int v in source) sum += v;
}
return sum;
}
这样,我们就学会了一个扩展方法的写法,何乐而不为呢?
编程的快乐,往往在乎一念之间。
PS:代码是从微软服务器上下载的,所以设置完毕后,第一次下载过程可能有点长。
更详细的文档如下:
Using the Microsoft Symbol Server to obtain symbol debugging information is now much easier in VS 2010. Microsoft gives you access to their internet symbol server that contains symbol files for most of the .NET framework including the recently announced availability of MVC 2 Symbols.
SETUP
In VS 2010 RTM, go to Tools –> Options –> Debugging –> General. Check “Enable .NET Framework source stepping”
We get the following dialog box
This automatically disables “Enable My Code”
Go to Debugging –> Symbols and Check “Microsoft Symbol Servers”. You can selectively exclude modules if you want to.
You will get a warning dialog like so:
Hitting OK will start the download process
The setup is complete. You are now ready to start debugging!
DEBUGGING
Add a break point to your application and run the application in debug mode (F5 shortcut for me). Go to your call stack when you hit the break point. Right click on a frame that is grayed out.
Select “Load Symbols from” “Microsoft Symbol Servers”. VS will begin a one time download of that assembly. This assembly will be cached locally so you don’t have to wait for the download the next time you debug the app.
We get a one time license agreement dialog box
You might see an error like the one below regarding different encoding (hopefully will be fixed).
Assemblies for which the symbols have been loaded are no longer grayed out. Double clicking on any entry in the call stack should now directly take you to the source code for that assembly.
AFAIK, not all symbols are available on the MS symbol server. In cases like that you will see a tab like the one below and be given the option to “Show Disassembly”.
Enjoy!
相关推荐
VC 高级界面类库FCL(Free Class Library),自由类库(Free Class Library 简称FCL),关于VC FCL高级界面库的几点说明: 1、本套类库目前还不能算是正式版,就连名字也是临时取的。发布它的目的是希望能和有着共同...
FCL框架,c#框架技术,可以看看,学习FCL可以看看
fcl flexible collision library 碰撞检测库源码
ICanSeeYou远程控制软件(所有C#源代码) 另外附有说明文档。 原程序(安装包)的下载地址: http://download1.csdn.net/down3/20070428/28022416404.rar<br/><br/>源代码说明: <br/>IDE(集成开发...
Renesas RH850_FCL Cflash 自编程代码,当前版本V2.12
C#.net.NET Framework由框架类库(FCL)和公共语言运行时(CLR)两个主要组件构成 CLR是管理用户代码执行的现代运行时环境,它提供JIT 编译、内存管理、异常管理和调试等方面的服务 CTS定义声明、定义和管理所有...
基于MATLAB环境下的FCL限流效果仿真分析.pdf
VC senior interface Library FCL (Free Class Library)
VC++ 高级界面类库FCL(Free Class Library)源程序
ccd 库源码,fcl 碰撞检测库的依赖库
资源来自pypi官网。 资源全名:python_fcl-0.0.12-cp27-cp27mu-manylinux1_x86_64.whl
数据融合matlab代码通过人为构图学习检测人与物体的交互(CVPR2021) 我们提出了一种伪造的成分学习方法来解决开放式长尾HOI检测。 该存储库是基于先前方法的代码构建的。 感谢他们的出色工作。 在此存储库中,我们...
simulation of power system with parallel resonance fcl
高级界面类库FCL(Free Class Library)源程序
这个是我在做一份作业的时候用到的三维碰撞检测方法。 对于两个模型中的每一个三角形,总共会有6种情况, 1)两个三角形形成的平面的交线上没有上述两个三角形之一 ...这段代码会分出几种情况然后回传是否碰撞。
节:用来调节控制卡脱机模式时,每秒切换的帧数,也就是说设置的越慢特技效果就会越慢。同步帧速率调节:用来调节控制卡同步模式时,每秒切换的帧数。显示屏刷新:调节显示屏刷新的hz数,设置的越快效果越平稳,但是...
基于MATLAB环境下的FCL限流效果仿真分析
本书针对clr、C#5.0和.net framework 4.5进行深入、全面的探讨,并结合实例介绍了如何利用它们进行设计、开发和调试。 本书深入、全面探讨.NET Framework、CRL和多核编程,广泛讨论FrameworkClassLibrary(FCL)核心...
Microsoft .NET Framework 2.0 FCL/BCL/RUNTIME,.NET虚拟机实现源代码!
fcl-latest1613461203471304333.log