Esempio n. 1
0
        private MetadataReference ResolveReference(string name)
        {
            if (_nuGetConfiguration != null)
            {
                name = _nuGetConfiguration.ResolveReference(name);
            }

            if (File.Exists(name))
            {
                return(RoslynHost.CreateMetadataReference(name));
            }
            try
            {
                var location = _gacResolver?.Resolve(name);
                if (location != null)
                {
                    return(RoslynHost.CreateMetadataReference(location));
                }
            }
            catch (Exception)
            {
            }

            return(null);
        }
 private MetadataReference ResolveReference(string name)
 {
     if (_nuGetConfiguration != null)
     {
         name = _nuGetConfiguration.ResolveReference(name);
     }
     if (File.Exists(name))
     {
         return(RoslynHost.CreateMetadataReference(name));
     }
     try
     {
         var assemblyName = GlobalAssemblyCache.Instance.ResolvePartialName(name);
         if (assemblyName == null)
         {
             return(null);
         }
         var assembly = Assembly.Load(assemblyName.ToString());
         return(RoslynHost.CreateMetadataReference(assembly.Location));
     }
     catch (Exception)
     {
         return(null);
     }
 }