Int-L Posted May 12, 2008 Posted May 12, 2008 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. Quote
Nate Bross Posted May 12, 2008 Posted May 12, 2008 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"; } } } Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.