I would like to share the following code snippet. This is to get the framework version that is used for a managed applications in the application pool of IIS 7.0

namespace iistest
{
    class Program
    {
        static void Main(string[] args)
        {
            Program p = new Program();
            Console.WriteLine(":" + p.GetAppPoolVersion("DefaultAppPool") + ":");
        }
        public string GetAppPoolVersion(String apppool)
        {
             String metabasePath = "IIS://localhost/W3SVC/AppPools/" + apppool;
            DirectoryEntry appPools = new DirectoryEntry(metabasePath);
            return appPools.Properties["ManagedRuntimeVersion"][0].ToString();
 
        }
      
 
    }
}