예제 #1
0
        static Assembly LoadAssemblyFromRunDir(object sender, ResolveEventArgs e)
        {
            try
            {
                var requestedName = e.Name.TrimSuffix(".dll", StringComparison.OrdinalIgnoreCase);
                var name          = new AssemblyName(requestedName).Name;
                if (!ourAssemblies.Contains(name, StringComparer.OrdinalIgnoreCase))
                {
                    return(null);
                }
                var path     = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                var filename = Path.Combine(path, name + ".dll");
                if (!File.Exists(filename))
                {
                    return(null);
                }

                return(Assembly.LoadFrom(filename));
            }
            catch (Exception ex)
            {
                var log = string.Format(CultureInfo.CurrentCulture,
                                        "Error occurred loading {0} from {1}.{2}{3}{4}",
                                        e.Name,
                                        Assembly.GetExecutingAssembly().Location,
                                        Environment.NewLine,
                                        ex,
                                        Environment.NewLine);
                VsOutputLogger.Write(log);
            }
            return(null);
        }
예제 #2
0
 static Assembly LoadAssemblyFromRunDir(object sender, ResolveEventArgs e)
 {
     try
     {
         var name = new AssemblyName(e.Name);
         if (!ourAssemblies.Contains(name.Name))
         {
             return(null);
         }
         //if (name.Name.Equals("GitHub.TeamFoundation", StringComparison.Ordinal))
         //    name = new AssemblyName("GitHub.TeamFoundation." + VSVersion);
         var path     = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
         var filename = Path.Combine(path, name.Name + ".dll");
         if (!File.Exists(filename))
         {
             return(null);
         }
         return(Assembly.LoadFrom(filename));
     }
     catch (Exception ex)
     {
         var log = string.Format(CultureInfo.CurrentCulture, "Error occurred loading {0} from {1}.{2}{3}{4}", e.Name, Assembly.GetExecutingAssembly().Location, Environment.NewLine, ex, Environment.NewLine);
         VsOutputLogger.Write(log);
     }
     return(null);
 }