Manually download. NET Framework source code

Source: Internet
Author: User
Tags mscorlib
A few months ago, Microsoft opened some. NET Framework source code. Visual Studio 2008 and Visual Studio 2005 users can obtain this code through the symbol server. However, unlike when editing an MFC program, Visual Studio only allows. Net programmers to open the. CS file related to the current code when debugging the program. These. CS files are not cached on the local disk. The files cached on the local disk are. PDB files, that is, Visual Studio program database ). We know that ,. PDB is a file that stores program debugging information and does not contain the program source code. net Framework source code is very inconvenient for users, so it is called. net mass downloader program came into being. For example,. net mass downloader is the download tool for bulk download of. NET Framework source code. It not only downloads. PDB files, but also downloads a series of. CS files corresponding to each. PDB file. This may not be in the commercial interests of Microsoft, but I have noticed that this software was released on Microsoft's open-source community codeplex. I guess its existence is approved by Microsoft .. Net mass downloader has been released for some time. I learned about it yesterday and occasionally downloaded its source code. An error occurs when you reinstall Visual Studio 2008. I installed Silverlight 2 Tools Beta 2 and then installed Visual Studio 2008 SP1 beta. As a result, the latter installation fails, prompting you to uninstall the kb944899 patch first. This patch happens to be related to the. NET Framework source code. However, I did not install kb944899. I guess it may be that Silverlight 2 Tools Beta 2 has installed another patch covering kb944899. This is indeed the case. The problem lies in kb949325. Everything works normally after kb949325 is uninstalled-I just opened the newly downloaded. net mass downloader source code to test whether Visual Studio 2008 is successfully installed. The following tutorial is a rough view of the. net mass downloader source code. Of course, with a tool like. net mass downloader, no one will actually download the. NET Framework source code manually. The purpose of this tutorial is to look at the working principles of the Microsoft symbol servers.
  1. Installing. NET Framework 3.5 is important but is often ignored. Currently, Microsoft only provides. net Framework 3.5 assembly (assembly) part of the source code, install other versions. net Framework, you may not download any code, because the Assembly with the same name is in different versions.. NET Framework. For example, all versions of the. NET Framework have the system. dll assembly. The version numbers of the. NET Framework are shown in the following table:
    . NET Framework Version System. dll version Compile date File Size
    1.0 1.0.3705.0 2002-1-5 1, 136kb
    1.1 1.1.4322.573 2003-2-21 1, 188kb
    2.0, 3.0 2.0.50727.42 2005-9-23 2, 948kb
    2.0 SP1, 3.0 SP1, 3.5 2.0.50727.1433 2007-10-24 3, 004kb
    3.5 SP1 Beta 2.0.50727.3031 2008-4-18 2, 964kb
    Obviously, if the file version is different, the source code is different. This is the reason for installing. NET Framework 3.5. I want to be more rigorous about this issue. To download the source code of. NET Framework, you do not have to install. NET Framework. Installing. NET Framework is just a simple method. After reading the following steps, we can know that what we really need here is the Assembly file corresponding to the source code to be downloaded, similar to system. dll in the above example. You have many ways to obtain this file, such as downloading the. NET Framework 3.5 installation package and manually extracting the file from it.
  2. Add a new User-Agent: Microsoft-symbol-server/6.8.0004.0 to the browser.
    • If your browser is Internet Explorer 7, you can go to the Registry HKEY_LOCAL_MACHINE/software/Microsoft/Windows/
      CurrentVersion/Internet Settings/5.0/user agent/post platform position new string (reg_sz), value: Microsoft-symbol-server/6.8.0004.0, data left blank.

    • If your browser is Firefox 3, you can create the General. useragent. Override string on the about: config page and set it to Microsoft-symbol-server/6.8.0004.0.
    • If you use other browsers, such as Maxthon, or have installed browser extensions such as ie7pro, you can try to set the User-Agent value in their configurations.
    This step allows the symbol server to recognize subsequent download requests. Restart the browser after setting.
  3. To retrieve the PDB information in the Assembly file, take mscorlib. dll 2.0.50727.1433 as an example. It is generally located in the C:/Windows/Microsoft. NET/framework/v2.0.50727 directory.
    • If you have installed visual c ++, you can use its command line tool dumpbin to export the PE structure information of the entire mscorlib. dll. Find the debug directories section. Note the value after format: RSDs, {56470dde-a10f-45f4-a409-7ff9274f4923}, 1, mscorlib. PDB.

      This is the data of the cv_info_pdb70 structure. The meaning is as follows:
      Type Name Value Description
      DWORD Cvsignature RSDs Indicates that the current codeview block format is PDB 7.0.
      Guid Signature {56470dde-a10f-45f4-a409-7ff9274f4923} Digital signature of the. PDB File
      DWORD Age 1 Incremental update ID of the. PDB File
      Byte [] Pdbfilename Mscorlib. PDB File Name Of The. PDB file ending with/x0
    • If you are familiar with the structure of PE/coff, you can use a normal hexadecimal editor to find the string "RSDs", or locate the following data in sequence based on the PE Structure:
    The data is used to locate the. PDB file on the symbol server.
  4. Download http://referencesource.microsoft.com/symbols/mscorlib.pdb/56470DDEA10F45F4A4097FF927
    4f000031/mscorlib. Pd _ It is not difficult to see how this address comes from:
    • First, the Microsoft symbolic server address is http://referencesource.microsoft.com/symbols;
    • The second is the file name mscorlib. pdb of the. PDB file;
    • Again, its guid 56470ddea10f45f4a4097ff9274f4923;
    • Then, Id 1 is updated incrementally;
    • Finally, it is the file name of. PDB. The difference is that the extension here is. Pd _.
    By the way, Downloading this file using Internet Explorer is often interrupted halfway, and the minidm of ie7pro does not support User-Agent settings. Therefore, Firefox is a better choice. You can use it to download it directly or by using the flashgot plug-in. For direct download, like Internet Explorer, the downloaded content is displayed on a webpage. In this case, the page cannot be saved directly, but the source code of the page should be opened, where the file is saved as mscorlib. Pd _.
  5. Decompress the downloaded mscorlib. pd_mscorlib.pd _ file in the cab format. Common compression tools support this format. You can also use the expand command line tool that comes with windows to decompress the package. Decompress the package to obtain mscorlib. PDB.
  6. Find the source code file in mscorlib. PDB and open mscorlib. PDB in a text editor. Find the character string srcsrv: ini ------------------------------------------ after garbled characters --------------------------------------------. The text starting from here records the file name and other necessary information of the mscorlib. DLL source code file. Note the following important name/value pairs:
    • Such as http_alias = http: // referencesource.microsoft.com/source/.net/8.0;
    • For example, http_extract_target = % http_alias %/% var2 %/% var3 %/% var4 %/% fnfile % (% var1 %) or,
    • Format: sd_extract_target = % targ %/% var2 %/% fnbksl % (% var3 %)/% var4 %/% fnfile % (% var1 %) logical address.
    To convert a logical address to a real address, you must also have the actual values of the preceding variables % x %. These values are like F: /redbits/NDP/CLR/src/Bcl/system/
    Object. CS * devdiv * depot/devdiv/releases/Whidbey/redbits/NDP/CLR/src/Bcl/system/object. CS * 1 strings. Take this string as an example. Its logical address is % targ %/% var2 %/% fnbksl % (% var3 %) /% var4 %/% fnfile % (% var1 % ).
    • Replace % targ % with the fixed address http: // referencesource.microsoft.com/source/.net/8.0. If the Logical Address Contains the variable % http_alias % instead of % targ %, replace it with the corresponding http_alias value;
    • The preceding string is divided into four sections by the star separator:
      • Replace % fnfile % (% var1 %) with the file name object. CS in section 1 );
      • Replace % var2 % with Section 2 devdiv;
      • Replace % var3 % with Section 3 depot/devdiv/releases/Whidbey/redbits/NDP/CLR/src/Bcl/system/object. CS;
      • Replace % var4 % with Section 4 1;
    • Replace the % fnbksl % slash in the brackets with the backslash.
    So we have a new address: http://referencesource.microsoft.com/source/.net/8.0/devdiv/depot/devdiv/releases/.
    Whidbey/redbits/NDP/CLR/src/Bcl/system/object. CS/1/object. CS.
  7. To download the source code of object. CS, open the above address in a browser. The Microsoft symbol server does not directly return the file to be downloaded, but returns an EULA (End User License Agreement ). Find the string in the Protocol, for example, accept = xxxxxxxxxxxxxxxxxxxxxxxxxx. Add the string to the end of the string as a parameter of the previous address. This gets the final address: http://referencesource.microsoft.com/source/.net/8.0/devdiv/depot/devdiv/releases/whidbey/
    Redbits/NDP/CLR/src/Bcl/system/object. CS/1/object. CS? Accept = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. This is the Source Code address of the object. CS to be downloaded.
At the time of writing this tutorial, Microsoft symbol servers was being adjusted and could not be connected from time to time, and the. Pd _ file versions downloaded were different. If this happens, try again the next day.

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.