private static Assembly LoadFromFabricCodePath(object sender, ResolveEventArgs args) { string assemblyName = new AssemblyName(args.Name).Name; if (!assemblyName.Equals(ServiceModelAssemblyName)) { return null; } try { string assemblyPath = Path.Combine(FabricCodePath, assemblyName + ".dll"); if (File.Exists(assemblyPath)) { return Assembly.LoadFrom(assemblyPath); } } catch (Exception) { // Suppress any Exception so that we can continue to // load the assembly through other means } return null; }
public Assembly GetAssembly(AssemblyName name, bool throwOnError) { Assembly assembly = null; if (this.cachedAssemblies == null) { this.cachedAssemblies = new Hashtable(); } if (this.cachedAssemblies.Contains(name)) { assembly = this.cachedAssemblies[name] as Assembly; } if (assembly == null) { assembly = Assembly.LoadWithPartialName(name.FullName); if (assembly != null) { this.cachedAssemblies[name] = assembly; return assembly; } if (this.names == null) { return assembly; } for (int i = 0; i < this.names.Length; i++) { if (name.Equals(this.names[i])) { try { assembly = Assembly.LoadFrom(this.GetPathOfAssembly(name)); if (assembly != null) { this.cachedAssemblies[name] = assembly; } } catch { if (throwOnError) { throw; } } } } } return assembly; }
public Assembly GetAssembly(AssemblyName name, bool throwOnError) { Assembly result = null; if (cachedAssemblies == null) { cachedAssemblies = Hashtable.Synchronized(new Hashtable()); } if (cachedAssemblies.Contains(name)) { result = cachedAssemblies[name] as Assembly; } if (result == null) { // try to load it first from the gac #pragma warning disable 0618 //Although LoadWithPartialName is obsolete, we still have to call it: changing //this would be breaking in cases where people edited their resource files by //hand. result = Assembly.LoadWithPartialName(name.FullName); #pragma warning restore 0618 if(result != null) { cachedAssemblies[name] = result; } else if (names != null) { for(int i=0;i<names.Length; i++) { if(name.Equals(names[i])) { try { result = Assembly.LoadFrom(GetPathOfAssembly(name)); if(result != null) { cachedAssemblies[name] = result; } } catch { if(throwOnError) { throw; } } } } } } return result; }