Scott on Writing

Musings on technical writing...

Exploring the Code for the New .NET 3.5 Classes

I often use the free and awesome decompiler Reflector to peer into the source code of Microsoft's .NET Framework. It's an indispensable tool. However, I had a little difficulty viewing the underlying source code for some of the new .NET 3.5 classes. In particular, for a recent article I was interested in looking at what was happening underneath the covers when the DataPager control was rendered. The DataPager is a new control in ASP.NET 3.5 used to render a paging interface for the ListView control (also new to 3.5).

By default, Reflector had the v2.0 assemblies loaded. “No problem,” I thought, “I'll just navigate to the 3.5 assemblies in the %WINDIR%\Microsoft.NET\Framework folder and open the System.Web assemby from there. While there is a 3.5 subfolder there, it only includes a sprinkling of assemblies, and none of the 3.5 assemblies I was interested in. The .NET 3.5-specific classes are installed in the GAC in the System.Web.Extensions.dll assembly. Reflector, it appears, can't locate this assembly and I couldn't reach it through Windows Explorer.

I was able to use Reflector to dig into this assembly, but I'm sure there's an easier way to do it. I'm going to share my approach, but I invite anyone who knows of a simpler technique to post instructions in the comments. One possible solution would be to update Visual Studio 2008 so that the .NET Framework code can be stepped into during debugging. I tried applying the hotfix a while back and got an error, and have not yet taken the time to investigate the error further. With the .NET Framework source code integration can you view the source code through VS 2008 like with Reflector, or is the code only accessible when debugging?

To open the System.Web.Extensions.dllfrom Reflector, perform the following steps:

  • Drop to the command line (Start / Run / cmd.exe)
  • Navigate to the appropriate GAC folder, %WINDIR%\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\
  • Copy the System.Web.Extensions.dll to another location on my hard drive (such as C:\MyAssemblies\).
  • Once the assembly is “freed” from the GAC, you can open it in Reflector as you would any assembly

Hope this helps!

UPDATE FROM JAMES NEWTON-KING: “You can access the 3.0 and 3.5 assemblies at C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5” (That sure simplifies things!)

posted on Thursday, February 14, 2008 11:08 AM

Feedback

# re: Exploring the Code for the New .NET 3.5 Classes 2/14/2008 12:08 PM James Newton-King

Scott you can access the 3.0 and 3.5 assemblies at C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5

# re: Exploring the Code for the New .NET 3.5 Classes 2/14/2008 12:25 PM Scott Mitchell

James, thanks for the heads up. That sure makes it easier than having to dig through the GAC.

# Exploring the Code for the New .NET 3.5 Classes 2/14/2008 12:30 PM DotNetKicks.com

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# re: Exploring the Code for the New .NET 3.5 Classes 2/14/2008 12:34 PM Joshua Johnson

Scott, have you seen this blog post from John Robbins about downloading the .NET 3.5 Source Code using a new utility? http://www.wintellect.com/cs/blogs/jrobbins/archive/2008/02/07/net-mass-downloader-1-1-released.aspx

and

http://www.wintellect.com/cs/blogs/jrobbins/archive/2008/02/14/net-mass-downloader-1-2-released.aspx

# re: Exploring the Code for the New .NET 3.5 Classes 2/14/2008 11:03 PM Stuart Leeks

You can also go to File\Open Cache in Reflector and then type System.Web.Extensions. Reflector will search through the GAC and list any extensions that match. It can take a while with several versions of .Net installed, but it's an easy way to get at assemblies in the GAC.

# re: Exploring the Code for the New .NET 3.5 Classes 1/13/2009 11:06 AM David Cater

(Not sure if that comment made it in the first time...trying to repost)

I'm trying to examine Microsoft.Synchronization.* (the assemblies for the Microsoft Sync Framework).

They do not appeared to be installed under c:\Program Files\Reference Assemblies.

I tried using File > Open Cache in Reflector, and typed in "sync". They were not found, although various other assemblies were.

I looked at the properties for the referenced assemblies in VS2008 and got the path to them. As Scott said originally, they were under c:\windows\assembly (in various subfolders). I went to an Admin command prompt and copied the dlls to c:\program files\reference assemblies\FreedFromGACByMe (a folder I created). I opened them in Reflector, and was able to see them.

Final analysis: for me, Scott's original method worked best.

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<July 2009>
SMTWTFS
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

Comment Stats

DayTotal% of Total
Sunday 2046.9%
Monday 42314.3%
Tuesday 50116.9%
Wednesday 54518.4%
Thursday 57219.3%
Friday 53618.1%
Saturday 1856.2%
Total 2966100.0%

Hour1Total% of Total
12:00 AM 752.5%
1:00 AM 802.7%
2:00 AM 672.3%
3:00 AM 812.7%
4:00 AM 642.2%
5:00 AM 1234.1%
6:00 AM 1153.9%
7:00 AM 1755.9%
8:00 AM 1876.3%
9:00 AM 1565.3%
10:00 AM 1866.3%
11:00 AM 1926.5%
12:00 PM 1996.7%
1:00 PM 1846.2%
2:00 PM 1675.6%
3:00 PM 1344.5%
4:00 PM 1153.9%
5:00 PM 1063.6%
6:00 PM 993.3%
7:00 PM 1063.6%
8:00 PM 903.0%
9:00 PM 842.8%
10:00 PM 893.0%
11:00 PM 923.1%
Total 2966100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 4.91157
Monday 4.92379
Tuesday 4.21471
Wednesday 7.42668
Thursday 6.53666
Friday 5.17450
Saturday 4.73175
Total 5.522966

Hour1 Entry MadeAvg.Total
12:00 AM 5.2937
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 4.0048
8:00 AM 4.29133
9:00 AM 6.04290
10:00 AM 5.83274
11:00 AM 4.36192
12:00 PM 6.44348
1:00 PM 3.14132
2:00 PM 5.04227
3:00 PM 7.97303
4:00 PM 3.8199
5:00 PM 6.00168
6:00 PM 4.56114
7:00 PM 8.95188
8:00 PM 8.58163
9:00 PM 5.00115
10:00 PM 6.31101
11:00 PM 4.5732
Total 5.522966

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles