public AddInServerWorker CreateDomain(AddInToken token, PermissionSet permissionSet)
        {
            AppDomain      domain;
            AppDomainSetup setup = new AppDomainSetup();

            setup.ApplicationBase   = Path.GetDirectoryName(token._addin.Location);
            setup.ConfigurationFile = token._addin.Location + ".config";

            Assembly sysCore = typeof(AddInActivator).Assembly;

            domain = AppDomain.CreateDomain(token.Name,
                                            AppDomain.CurrentDomain.Evidence, setup, permissionSet,
                                            AddInActivator.CreateStrongName(sysCore)); // Grant full trust to System.Core.dll

            // Ensure we load System.Core.dll in this new AD.
            domain.Load(sysCore.FullName);

            ObjectHandle      workerHandle = Activator.CreateInstance(domain, sysCore.FullName, typeof(AddInServerWorker).FullName);
            AddInServerWorker server       = (AddInServerWorker)workerHandle.Unwrap();

            server.AddInServer = this;

            Interlocked.Increment(ref _addInAppDomains);

            return(server);
        }
        public T Activate <T>(AppDomain target)
        {
            if (target != AppDomain.CurrentDomain && !Utils.HasFullTrust())
            {
                throw new SecurityException(Res.PartialTrustCannotActivate);
            }

            return(AddInActivator.Activate <T>(this, target));
        }
        public T Activate <T>(PermissionSet permissions)
        {
            if (permissions == null)
            {
                throw new ArgumentNullException("permissions");
            }
            System.Diagnostics.Contracts.Contract.EndContractBlock();

            return(AddInActivator.Activate <T>(this, permissions));
        }
        internal System.AddIn.Contract.IContract CreateAddInAdapter(Object addIn, Assembly addinAdapterAssembly)
        {
            System.Diagnostics.Contracts.Contract.Ensures(System.Diagnostics.Contracts.Contract.Result <System.AddIn.Contract.IContract>() != null);

            // Create the AddIn Adapter
            System.AddIn.Contract.IContract addInAdapter = null;
            _currentComponentType = PipelineComponentType.AddInAdapter;
            Type adapterType   = addinAdapterAssembly.GetType(_pipeline._addinAdapter.TypeInfo.FullName, true);
            Type addInBaseType = Type.GetType(_pipeline._addinBase.TypeInfo.AssemblyQualifiedName, true);

            AddInActivator.InvokerDelegate myInvokerDelegate = AddInActivator.CreateConsInvoker(adapterType, addIn.GetType());
            addInAdapter = (System.AddIn.Contract.IContract)myInvokerDelegate(addIn);

            System.Diagnostics.Contracts.Contract.Assert(addInAdapter != null, "CreateInstance didn't create the add-in adapter");

            return(addInAdapter);
        }
 public T Activate <T>(AddInEnvironment environment)
 {
     return(AddInActivator.Activate <T>(this, environment));
 }
 public T Activate <T>(AddInProcess process, AddInSecurityLevel level)
 {
     return(AddInActivator.Activate <T>(this, process, level));
 }
 public T Activate <T>(AddInProcess process, PermissionSet permissionSet)
 {
     return(AddInActivator.Activate <T>(this, process, permissionSet));
 }
 public T Activate <T>(AddInSecurityLevel trustLevel, String appDomainName)
 {
     return(AddInActivator.Activate <T>(this, trustLevel, appDomainName));
 }
 public T Activate <T>(AddInSecurityLevel trustLevel)
 {
     return(AddInActivator.Activate <T>(this, trustLevel));
 }