System.Web.HttpRuntime.ResolveAssemblyHandler C# (CSharp) Method

ResolveAssemblyHandler() static private method

static private ResolveAssemblyHandler ( object sender, ResolveEventArgs e ) : Assembly
sender object
e ResolveEventArgs
return Assembly
		static Assembly ResolveAssemblyHandler(object sender, ResolveEventArgs e)
		{
			AssemblyName an = new AssemblyName (e.Name);
			string dynamic_base = AppDomain.CurrentDomain.SetupInformation.DynamicBase;
			string compiled = Path.Combine (dynamic_base, an.Name + ".compiled");
			string asmPath;

			if (!File.Exists (compiled)) {
				string fn = an.FullName;
				if (!RegisteredAssemblies.Find ((uint)fn.GetHashCode (), fn, out asmPath))
					return null;
			} else {
				PreservationFile pf;
				try {
					pf = new PreservationFile (compiled);
				} catch (Exception ex) {
					throw new HttpException (
						String.Format ("Failed to read preservation file {0}", an.Name + ".compiled"),
						ex);
				}
				asmPath = Path.Combine (dynamic_base, pf.Assembly + ".dll");
			}

			if (String.IsNullOrEmpty (asmPath))
				return null;
			
			Assembly ret = null;
			try {
				ret = Assembly.LoadFrom (asmPath);
			} catch (Exception) {
				// ignore
			}
			
			return ret;
		}