Thursday, April 7, 2011

Listing down .netassembly names

How many assembles do we have in .NET 3.5? Can I list them down For eg: System; System.Windows.Forms and so on...Please help with code in C#

From stackoverflow
  • What is the use of this other than being just a statistic? You do not have to include all of them in one single application anyway!

  • I need to display the list to my students..they are interested in seeing if it can be done and if we can list only the assembles(class names) of .net 3.5

  • take a look at gac c:\windows\assemblies

  • You can download the .NET Framework 3.5 Common Namespaces and Types Poster on Microsoft's website.

  • isnt there any way to display it using reflection? I just need the class names in .net 3.5

  • Here's a quick program to search C:\Windows\assembly\ for all .dll assemblies and output the ones with a version of 3.5:

    // Get all "*.dll" files from "C:\Windows\assembly".
    string windowsDirectory = Environment.GetEnvironmentVariable( "windir" );
    string assemblyDirectory = Path.Combine( windowsDirectory, "assembly" );
    string[] assemblyFiles = Directory.GetFiles(
      assemblyDirectory, "*.dll", SearchOption.AllDirectories
    );
    
    // Get version of each file (ignoring policy, integration, and design files).
    var versionedFiles =
      from path in assemblyFiles
      let filename = Path.GetFileNameWithoutExtension( path )
      where !filename.StartsWith( "policy" ) 
         && !filename.EndsWith( ".ni" ) 
         && !filename.EndsWith( ".Design" )
      let versionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo( path )
      select new { Name = filename, Version = versionInfo.FileVersion };
    
    // Select all 3.5 assemblies.
    var assembliesIn3_5 = versionedFiles
      .Where( file => file.Version.StartsWith( "3.5" ) )
      .OrderBy( file => file.Name );
    
    foreach( var file in assembliesIn3_5 )
      Console.WriteLine( "{0,-50} {1}", file.Name, file.Version );
    

    Based on this PowerShell query:

    dir C:\Windows\assembly -filter *.dll -recurse | 
      ? { [Diagnostics.FileVersionInfo]::GetVersionInfo($_.FullName).FileVersion.StartsWith('3.5.') } | 
      % { [IO.Path]::GetFileNameWithoutExtension($_.Name) } | 
      ? { -not $_.EndsWith('.ni') } | 
      sort
    


    Also, you mind find Hanselman's Changes in the .NET BCL between 2.0 and 3.5 post useful.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.