none
How to get Latest Version of Assembly from GAC RRS feed

  • General discussion

  • Hi,

    How can I get Latest version of Assembly from GAC?

    I tried by using LoadWithPartialName option. Is working fine. But I found that "The LoadWithPartialName method is obsolete in .NET Framework version 2.0." Any one know an alternative option for LoadWithPartialName .

    Regards,

    Vidya


    Friday, January 20, 2012 6:03 AM

All replies

  • You could try System.Diagnostics.FileVersionInfo .
    Regards, MusicDemon
    Friday, January 20, 2012 7:57 AM
  • Hi  MusicDemon,

    I tried with the above link. For notepad its working fine. But for Gac dlls its showing" file not found exception (C:\Windows\assembly\Microsoft.SqlServer.ConnectionInfo.dll)" .

    I tried with the below code

     

     FileVersionInfo.GetVersionInfo(Path.Combine("C:\\Windows\\assembly", "Microsoft.SqlServer.ConnectionInfo.dll"));
    
     FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo("C:\\Windows\\assembly\\Microsoft.Sqlserver.Smo.dll");
    


    Could you please correct me if I am wrong or please suggest me any other solution.

    Regards,

    Vidya

     


    Friday, January 20, 2012 11:50 AM
  • It's a directory that has a custom "skin". It's actually a big tree of assemblies. (Never knew)

     

    Use: DirectoryInfo[] di = new DirectoryInfo(@"C:\Windows\assembly").GetDirectories();

    C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Smo\10.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Smo.dll

    That is the path that has been returned for me.

    I used the following method:

     

    using System;
    using System.IO;
    using System.Diagnostics;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                chkDir(new DirectoryInfo(@"C:\Windows\assembly"));
            }
    
            static void chkDir(DirectoryInfo dir)
            {
                if (dir.Name.Equals("Microsoft.Sqlserver.Smo", StringComparison.InvariantCultureIgnoreCase))
                    Debug.Print(dir.GetDirectories()[0].GetFiles()[0].FullName);
                foreach (var tdir in dir.GetDirectories())
                    chkDir(tdir);
            }
        }
    }
    
    


    EDIT: Why aren't you using:

    Type t = typeof(System.Sqlserver.Smo.SmClass1);



    Regards, MusicDemon
    • Edited by MusicDemon Friday, January 20, 2012 7:09 PM
    Friday, January 20, 2012 6:51 PM