Get project references

Int-L

Newcomer
Joined
May 12, 2008
Messages
1
Hi all,

I'm working on an application in which i need to read the references of the project itself.

Is there any idea to get the projects references and display their names?
Ex :

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
etc....

Thanks.
 
You can load the .csproj file to determine binaries referenced:
From my sample C# .csproj file (in notepad)
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.DirectoryServices" />
<Reference Include="System.DirectoryServices.AccountManagement">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>

You can look for "using" in each .cs file to see what is used by code:
pseudocode
C#:
string Ref = String.Empty;
foreach(file in IO.Directory.GetFiles("C:\Project\Directory\"))
{
    foreach(line in file)
    {
        If(line.StartsWith("System."))
        {
            Ref += line + "\r\n";
        }

    }
}
 
Back
Top