From da30c35395033f53e1ddd70fb49ab5178888352d Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 28 Apr 2004 19:01:06 +0000 Subject: [PATCH] * driver.cs: Attempt to load referenced assemblies from the GAC. This is the quick and dirty version of this method that doesnt take into account versions and just takes the first canidate found. Will be good enough for now as we will not have more then one version installed into the GAC until I update this method. svn path=/trunk/mcs/; revision=26190 --- mcs/mcs/ChangeLog | 9 +++++++++ mcs/mcs/driver.cs | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog index b5d7c677530..44faa4cefc5 100755 --- a/mcs/mcs/ChangeLog +++ b/mcs/mcs/ChangeLog @@ -1,3 +1,11 @@ +2004-04-28 Jackson Harper + + * driver.cs: Attempt to load referenced assemblies from the + GAC. This is the quick and dirty version of this method that + doesnt take into account versions and just takes the first + canidate found. Will be good enough for now as we will not have more + then one version installed into the GAC until I update this method. + 2004-04-28 Martin Baulig * typemanager.cs (TypeManager.CheckStructCycles): New public @@ -93,6 +101,7 @@ for a named field or property, implicity convert it to the correct type. +>>>>>>> 1.1450 2004-04-27 Raja R Harinath * statement.cs (Block.Block): Implicit blocks share diff --git a/mcs/mcs/driver.cs b/mcs/mcs/driver.cs index 19fcf1abb8b..25202b3b856 100755 --- a/mcs/mcs/driver.cs +++ b/mcs/mcs/driver.cs @@ -289,7 +289,9 @@ namespace Mono.CSharp if (assembly.IndexOfAny (path_chars) != -1) { a = Assembly.LoadFrom (assembly); } else { - a = Assembly.Load (assembly); + a = LoadAssemblyFromGac (assembly); + if (a == null) + a = Assembly.Load (assembly); } TypeManager.AddAssembly (a); @@ -321,6 +323,37 @@ namespace Mono.CSharp } } + static Assembly LoadAssemblyFromGac (string name) + { + PropertyInfo gac = typeof (System.Environment).GetProperty ("GacPath", + BindingFlags.Static|BindingFlags.NonPublic); + + if (gac == null) + return null; + + MethodInfo gac_get = gac.GetGetMethod (true); + string use_name = name; + string asmb_path; + string [] canidates; + + if (name.EndsWith (".dll")) + use_name = name.Substring (0, name.Length - 4); + + asmb_path = Path.Combine ((string) gac_get.Invoke (null, null), use_name); + + if (!Directory.Exists (asmb_path)) + return null; + + canidates = Directory.GetDirectories (asmb_path); + + try { + Assembly a = Assembly.LoadFrom (Path.Combine (canidates [0], use_name + ".dll")); + return a; + } catch (Exception e) { + return null; + } + } + static public void LoadModule (MethodInfo adder_method, string module) { Module m; -- 2.25.1