private Assembly GetSatelliteAssembly (CultureInfo culture, Version version, bool throwOnError)
{
if (culture == null)
throw new ArgumentException ("culture");
AssemblyName aname = GetName (true);
if (version != null)
aname.Version = version;
aname.CultureInfo = culture;
aname.Name = aname.Name + ".resources";
Assembly assembly;
try {
assembly = AppDomain.CurrentDomain.LoadSatellite (aname, false);
if (assembly != null)
return assembly;
} catch (FileNotFoundException) {
assembly = null;
// ignore
}
// Try the assembly directory
string location = Path.GetDirectoryName (Location);
string fullName = Path.Combine (location, Path.Combine (culture.Name, aname.Name + ".dll"));
#if NET_2_1 && !MONOTOUCH
// it's unlikely that culture.Name or aname.Name could contain stuff like ".." but...
fullName = Path.GetFullPath (fullName);
if (!fullName.StartsWith (location)) {
if (throwOnError)
throw new SecurityException ("non-rooted access to satellite assembly");
return null;
}
#endif
if (!throwOnError && !File.Exists (fullName))
return null;
return LoadFrom (fullName);
}