Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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

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";
       }

   }
}

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...