Tuesday, March 25, 2008

How to attach .NET sources in VS 2005

1. Download "Mass Downloader" from project site.

2. Unzip content of downloaded file NetMassDownloader.zip.

3. Run utility with next parameters:

NetMassDownloader.exe -vsver 8.0 -d C:\Windows\Microsoft.NET\Framework\v2.0.50727 -output D:\ReferenceSource_VS2005

where

folder D:\ReferenceSource_VS2005 is a target folder to download .NET sources.

Process of sources downloading had took 90 minutes on my computer with my Internet connection.

referenceSources_VS2005

4. It is necessary to add the folder to "Symbol file locations".

referenceSources_SetDebuggingSymbols

5. Uncheck "Require sources files to exactly match the original version" settings.

referenceSources_SetDebuggingRequireSources

6. Uncheck option "Enable Just My Code (Managed only):

referenceSources_SetDebuggingJustMyCode

7. In each solution, where we want to access to .NET sources, it is necessary to add next directory:

referenceSources_SetSolutionSettings

Now, when we debug next code:

static voidMain(){ int[] array = (int[]) Array.CreateInstance(typeof (int), 10);
//SampleFindAll();
//SampleFindIndex();
}
we can enter to .NET sources code (file Array.cs) by command "Step Into":

// Create instance will create an array
public unsafe static Array CreateInstance(Type elementType, int length)
{
if (elementType == null)
throw new ArgumentNullException("elementType");
RuntimeType t = elementType.UnderlyingSystemType as RuntimeType;
if (t == null)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),"elementType");
if (length < 0)
throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
return InternalCreate((void*)t.TypeHandle.Value,1,&length,null);
}

Reference:

View the .NET Sources Code in VS 2005

No comments: