public static void ScanAssemblyForHandlers(Assembly assembly) { try { //Locate JSONObjects and JSONRequestImplementations in the assembly. var objects = assembly.GetTypes() .Where(t => t.GetInterfaces() .Any(i => i.Equals(typeof(JSONObject)))) .Where(t => !JSONObjects.Contains(t)).AsEnumerable(); var handlers = assembly.GetTypes() .Where(t => t.GetInterfaces() .Any(i => i.Equals(typeof(IJSONRequestImplementationCore))) && t.IsAbstract == false && t.IsInterface == false) .Where(t => !JSONObjects.Contains(t)).AsEnumerable(); //Add the JSONObjects and JSONRequestImplementations to their respective caches. JSONObjects.AddRange(objects); JSONRequestImplementations.AddRange(handlers); //Map each handler to it's json formatted name ([TypeName].json) foreach (var handler in handlers) { string hName = handler.Name; if (hName.Contains("`")) { hName = hName.Substring(0, hName.IndexOf("`")); } MapRequestToType(string.Format("{0}.json", hName), handler); } } catch (ReflectionTypeLoadException ex) { StringBuilder sb = new StringBuilder(); foreach (Exception exSub in ex.LoaderExceptions) { sb.AppendLine(exSub.Message); FileNotFoundException exFileNotFound = exSub as FileNotFoundException; if (exFileNotFound != null) { if (!string.IsNullOrEmpty(exFileNotFound.FusionLog)) { sb.AppendLine("Fusion Log:"); sb.AppendLine(exFileNotFound.FusionLog); } } sb.AppendLine(); } string errorMessage = sb.ToString(); throw ex; } }