+ class AssemblyPathResolver
+ {
+ static Dictionary <string, string> assemblyCache;
+
+ static AssemblyPathResolver ()
+ {
+ assemblyCache = new Dictionary <string, string> ();
+ }
+
+ public static string GetAssemblyPath (string assemblyName)
+ {
+ lock (assemblyCache) {
+ if (assemblyCache.ContainsKey (assemblyName))
+ return assemblyCache [assemblyName];
+
+ Assembly asm = null;
+ Exception error = null;
+ if (assemblyName.IndexOf (',') != -1) {
+ try {
+ asm = Assembly.Load (assemblyName);
+ } catch (Exception e) {
+ error = e;
+ }
+ }
+
+ if (asm == null) {
+ try {
+ asm = Assembly.LoadWithPartialName (assemblyName);
+ } catch (Exception e) {
+ error = e;
+ }
+ }
+
+ if (asm == null)
+ throw new HttpException (String.Format ("Unable to find assembly {0}", assemblyName), error);
+
+ string path = new Uri (asm.CodeBase).LocalPath;
+ assemblyCache.Add (assemblyName, path);
+ return path;
+ }
+ }
+ }
+