示例#1
0
        // Create the window.  No assemblies will be displayed.
        public DependenciesForm(LoadAssemblyInfo lai)
        {
            m_lai = new LoadAssemblyInfo();
            m_lai.LoadAs(lai.LoadAs());
            m_lai.AppPath(lai.AppPath());
            m_lai.RelPath(lai.RelPath());

            InitializeComponent();
        }
示例#2
0
        // Creates the window with a tree view of dependant assemblies/files.
        public DependenciesForm(ICollection names, LoadAssemblyInfo cai)
        {
            m_lai = cai;

            InitializeComponent();
            if (names.Count > 0)
            {
                _create_manifest(names);
            }
        }
示例#3
0
        // Builds the list of Dependencies for the Assembly Manifest located in the
        // file ``name''.
        //
        // If ``name'' couldn't be loaded, an exception is thrown as the manifest
        // file doesn't exist or is invalid.  If one of ``names'' dependency's
        // can't be loaded, an exception is not thrown; instead, the
        // IAssemblyInfo object returned will hold exception information.
        //
        public AssemblyDependencies(string name, LoadAssemblyInfo cai)
        {
            AssemblyRef ar = null;

            m_load = LoadAssembly.CreateLoader(cai);
            try
            {
                Trace.WriteLine("Name: " + name);

                AssemblyName an = m_load.GetAssemblyName(name);

                Trace.WriteLine("assembly name: " + an.Name);
                Trace.WriteLine("assembly full name: " + an.FullName);

                ar = m_load.LoadAssemblyName(an);

                Trace.WriteLine("Successfully loaded assembly.");
            }
            catch (Exception e)
            {
                Trace.WriteLine("m_load.LoadAssemblyName threw an exception:\n  " +
                                e.ToString());
                Trace.WriteLine("\tStackTrace: " + e.StackTrace);

                /*
                 * If ``m_load.LoadAssemblyName'' throws an exception, we want
                 * our caller to get the exception.  However, since this is
                 * the constructor, we need to clean up any allocated resources --
                 * in this case, the resouces of the LoadAssembly object.
                 */
                m_load.Dispose();
                throw e;
            }

            m_name = ar.FullName;

            IList search = new ArrayList();

            // Add the top-level object, the Assembly containing the manifest.
            // ``search'' will contain any Assemblies that the added object
            // references.
            m_map.Add(m_name, new AssemblyInfo(ar, search));

            // Get all referenced Assemblies.
            _traverse(search);
        }
示例#4
0
        // Create a LoadAssembly object based on ``i''.
        //
        // If ``i.LoadAs()'' doesn't return a value from the AssemblyLoadAs
        // enumeration, then an exception is thrown.
        public static LoadAssembly CreateLoader(LoadAssemblyInfo i)
        {
            Trace.WriteLine("Creating Assembly Loader for:");
            Trace.WriteLine("  LoadAs: " + i.LoadAs().ToString());
            Trace.WriteLine("  AppBasePath: " + i.AppPath());
            Trace.WriteLine("  RelativeSearchPath: " + i.RelPath());

            _creator c = (_creator)m_tbl[i.LoadAs()];

            if (c == null)
            {
                throw
                    new Exception("Internal error: Invalid AssemblyLoadAs specified");
            }

            return(c(i));
        }
示例#5
0
        public static void Main(string[] args)
        {
            ParseOptions po = null;

            try
            {
                po = new ParseOptions(args);
            }
            catch (OptionException e)
            {
                _exit(e.Message);
            }

            if (po.Help)
            {
                _print_help();
            }
            else if (po.Gui)
            {
                // if we've been asked to take over this process...
                if (po.TakeOverCurrentProcess)
                {
                    Application.Run(
                        new DependenciesForm(po.Files, po.LoadAssemblyInfo));
                }
                else
                {
                    // ...otherwise, spawn a new process.
                    _create_gui_process(po.SerializeOptions());
                }
            }
            else
            {
                // console output.
                m_lai    = po.LoadAssemblyInfo;
                m_config = po.ConfigurationFile;
                _display_files(po.Files);
            }
        }
示例#6
0
        // Create a new AppDomain to load the assembly ``an''.
        protected static AppDomain CreateAppDomain(AssemblyName an,
                                                   LoadAssemblyInfo info)
        {
            Trace.WriteLine("Loading a custom assembly for: " + an.FullName);
            String fname = String.Format(Localization.FMT_APPDOMAIN_NAME,
                                         an.FullName);

            Trace.WriteLine("  -- Friendly Name of new AppDomain: " + fname);

            Debug.Assert(an.CodeBase != null,
                         "The AssemblyName CodeBase must be set!");

            /*
             * The Application Base Path used to create the domain should be the
             * directory that the Assembly is located in.  If AppPath() is null,
             * then we should consult use the AssemblyName's CodeBase as the App
             * Base Path.
             */
            String appbase = info.AppPath();

            if (appbase == null)
            {
                appbase = _furi_to_dir(an.CodeBase);
            }

            AppDomain ad = AppDomain.CreateDomain(
                fname,          // friendlyName
                null,           // securityInfo
                appbase,        // appBasePath
                info.RelPath(), // relativeSearchPath
                false           // shadowCopyFiles
                );

            Trace.WriteLine("  -- created AppDomain");

            return(ad);
        }
示例#7
0
 private static LoadAssembly _create_custom_get(LoadAssemblyInfo cai)
 {
     return(new LoadCustomGetAssembly(cai));
 }
示例#8
0
 private static LoadAssembly _create_default(LoadAssemblyInfo cai)
 {
     return(new LoadDefaultAssembly());
 }
示例#9
0
 internal LoadCustomGetAssembly(LoadAssemblyInfo i)
     : base(i)
 {
 }
示例#10
0
 internal LoadCustomAssembly(LoadAssemblyInfo i)
 {
     m_info = i;
 }