コード例 #1
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.
        internal 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));
        }
コード例 #2
0
        // Create the Assembly in its own AppDOmain.  In doing so, it
        // uses the custom paths (AppBase and Relative)
        // specified by the LoadAssemblyInfo object passed when this
        // object was created.
        internal override AssemblyRef LoadAssemblyFrom(AssemblyName an)
        {
            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);
            AppDomain ad = AppDomain.CreateDomain(
                an.FullName,      // friendlyName
                null,             // securityInfo
                m_info.AppPath(), // appBasePath
                m_info.RelPath(), // relativeSearchPath
                false             // shadowCopyFiles
                );

            m_ads.Add(ad);
            Trace.WriteLine("  -- created AppDomain");

            Type   t     = typeof(AssemblyRef);
            string aname = Assembly.GetExecutingAssembly().FullName;

            Trace.WriteLine("Assembly containing AssemblyRef: " + aname);
            Trace.WriteLine("Type full name: " + t.FullName);
            Trace.WriteLine("Type name: " + t.Name);

            ObjectHandle oh = ad.CreateInstance(
                aname,                                                             // Assembly file name
                t.FullName,                                                        // Type name
                false,                                                             // ignore case
                BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, // binding attributes
                null,                                                              // binder
                null,                                                              // args
                null,                                                              // culture info
                null,                                                              // activation attributes
                Assembly.GetExecutingAssembly().Evidence                           // security attributes
                );

            AssemblyRef ar = (AssemblyRef)oh.Unwrap();

            ar.Load(an);
            return(ar);
        }