Debug source code in. NET Framework

Source: Internet
Author: User
ArticleDirectory
    • 1.1.1 Basic settings
    • 1.1.2 Debug. NET Framework source code

Abstract: I have heard that Microsoft has published some. NET Framework classes. We can use vs2008 for debugging and check. Recently, I tried this function to debug Microsoft'sSource codeThe general feeling is that Microsoft is still taking a big step towards open source, but it feels that debugging operations are very troublesome and can only be viewed as not allowed to make any modifications, it is better to view it through decompilation. In addition, if Microsoft can automatically generate some class diagrams of. NET Framework, it will be very good.

1.1.1 Basic settings

Make sure that the Visual Studio 2008 version (except Express versions) has the. NET Framework source for debugging.CodeFunction (it is best to install SP1 first ).

1) Now we need to download a patch Visual Studio 2008 QFE to update the DLL file in the debugging function of vs2008.

2) Run vs2008, select Tools> Options> debugging> General, and then modify the general settings as follows:

Deselect enable just my code)

Select enable source server support)

Figure 1 setting in debugging

 

3) Next, add the settings in the "symbol". First, set the symbol file, and enter a URL address http://referencesource.microsoft.com/symbols. then, we can set a token to be saved. Then select "manually load the symbol only to search for the above position ".

Figure 2 set in symbol

 

1.1.2 Debug. NET Framework source code

After completing the preceding simple installation and setup, We can debug the source code. Let's create a simple winformProgramTest the debugging effect. Add the following code. When Debugging starts, vs automatically downloads the DLL file for debugging source code.

Figure 3 download and debug the DLL file

 

 

Figure 4 set a debugging breakpoint

 

When we started debugging, we found that vs would become very slow because we wanted to download the debugging source code provided by. NET Framework from Microsoft. After the download is complete, we can open the breakpoint.

Next, we want to select the location where the symbol is loaded. We select a DLL file in the stack window, right-click it, and select load symbol. Here we can load it from the Network (very slow) or perform debugging based on the source code file address that has been downloaded. (Select local load)

Figure 5 select the Loading Method

Because I have loaded the symbolic file, no need to set it here. Now we can press F11 or directly click the DLL file in the stack window to go to source code debugging.

If the DLL file we want to enter is not found in the stack window, we can manually add it. For example, we added the paint Method to the form, but we did not find the system in the stack window. to add the DLL file of drawing.

 

Figure 6 manually add a DLL file

Now we can debug. net Framework source code, but we find that every debugging of Vs will download the symbol file, which slows down the running of vs. This is because every debugging has to re-load the symbol file from Microsoft, but we have downloaded the symbol file and saved it locally. Remember? We have configured loading from the internet before, so we can disable the download and debugging function and use a local file for debugging.

As mentioned above, we need to download all the debuggable DLL files provided by Microsoft locally, so we need to ensure that all the debugging files are downloaded once, as a result, we can only modify the debugging settings.

 

Figure 7 select the Loading Method

Now we can re-debug the program. It takes a long time to download the symbolic file, because this time we will download all the DLL files provided by Microsoft to the local machine and the file size is 50 MB, after the download is complete, vs automatically enters the breakpoint. Then we stop debugging and deselect the option of downloading the symbolic file from Microsoft, because we need to debug the file locally.

Figure 8 unselect

Now we can load local debugging files for debugging, so as not to affect the running efficiency of. Microsoft officially provides the following DLL file for debugging. I believe Microsoft will provide more DLL files for debugging in the future. Now, we can not only view the source code through the Anti-compiler, you can also breakpoint debug the source code even if you cannot modify the source code:

    • mscorlib. dll
    • system. dll
    • system. Data. dll
    • system. Drawing. dll
    • system. Web. dll
    • system. Web. Extensions. dll
    • system. Windows. Forms. dll
    • system. xml. dll
    • WPF (uiautomation *. DLL, system. windows. DLL, system. printing. DLL, system. speech. DLL, windowsbase. DLL, windowsformsintegration. DLL, presentation *. DLL, some others)
    • Microsoft. VisualBasic. dll

For more information, seeShawn Burke's blog

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.