string[] IAssemblyLocator.GetModules(string appdir, string appName, string name) { string[] strArray2; if ((appdir != null) && (appdir.Length > 0)) { AssemblyLocator locator = null; try { AppDomainSetup info = new AppDomainSetup { ApplicationBase = appdir }; AppDomain domain = AppDomain.CreateDomain(appName, null, info); if (domain != null) { ObjectHandle handle = domain.CreateInstance(typeof(AssemblyLocator).Assembly.FullName, typeof(AssemblyLocator).FullName); if (handle != null) { locator = (AssemblyLocator)handle.Unwrap(); } } } catch (Exception exception) { if ((exception is NullReferenceException) || (exception is SEHException)) { throw; } return(null); } return(((IAssemblyLocator)locator).GetModules(null, null, name)); } try { Module[] modules = Assembly.Load(name).GetModules(); string[] strArray = new string[modules.Length]; for (int i = 0; i < modules.Length; i++) { strArray[i] = modules[i].FullyQualifiedName; } strArray2 = strArray; } catch (Exception exception2) { if ((exception2 is NullReferenceException) || (exception2 is SEHException)) { throw; } throw exception2; } return(strArray2); }
/// <include file='doc\ExportUtil.uex' path='docs/doc[@for="AssemblyLocator.IAssemblyLocator.GetModules"]/*' /> String[] IAssemblyLocator.GetModules(String appdir, String appName, String name) { DBG.Info(DBG.Registration, "Finding modules for \"" + name + "\" at \"" + appdir + "\" in \"" + appName + "\""); if (appdir != null && appdir.Length > 0) { AssemblyLocator loc = null; try { // Spawn off an app-domain with the given directory as // the root search path: AppDomainSetup domainOptions = new AppDomainSetup(); domainOptions.ApplicationBase = appdir; AppDomain domain = AppDomain.CreateDomain(appName, null, domainOptions); if (domain != null) { AssemblyName n = typeof(AssemblyLocator).Assembly.GetName(); ObjectHandle h = domain.CreateInstance(n.FullName, typeof(AssemblyLocator).FullName); if (h != null) { loc = (AssemblyLocator)h.Unwrap(); } } } catch (Exception e) { DBG.Info(DBG.Registration, "Exception: " + e); return(null); } return(((IAssemblyLocator)loc).GetModules(null, null, name)); } // Otherwise, Just load the assembly and be done with it: try { Assembly asm = Assembly.Load(name); if (asm == null) { // TODO: error? DBG.Info(DBG.Registration, "Couldn't load assembly!"); } Module[] modules = asm.GetModules(); String[] names = new String[modules.Length]; for (int i = 0; i < modules.Length; i++) { names[i] = modules[i].FullyQualifiedName; } return(names); } catch (Exception e) { DBG.Info(DBG.Registration, "Exception loading assembly: " + e); throw e; } }