public AddInServerWorker()
        {
            PermissionSet permissionSet = new PermissionSet(PermissionState.None);

            permissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.ControlPrincipal));
            permissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.UnmanagedCode));
            permissionSet.AddPermission(new ReflectionPermission(PermissionState.Unrestricted));
            permissionSet.Assert();

            // without this call to initialize the client channel, this object cannot be remoted
            RemotingHelper.InitializeClientChannel();
        }
Пример #2
0
        public AddInProcess(Platform platform)
        {
            _platform = platform;

            // Process the arguments early so we can throw an exception if they were invalid.
            String folder  = RuntimeEnvironment.GetRuntimeDirectory();
            String exeName = GetProcessName(platform);

            _pathToAddInProcess = Path.Combine(folder, exeName);
            if (!File.Exists(_pathToAddInProcess))
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Res.MissingAddInProcessExecutable, _pathToAddInProcess));
            }

            // Eagerly call this.  Any MBRO objects created before this initialization
            // will not be usable.
            RemotingHelper.InitializeClientChannel();
        }
Пример #3
0
        internal static T Activate <T>(AddInToken token, AddInProcess process, PermissionSet permissionSet)
        {
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }
            if (permissionSet == null)
            {
                throw new ArgumentNullException("permissionSet");
            }
            if (process == null)
            {
                throw new ArgumentNullException("process");
            }
            System.Diagnostics.Contracts.Contract.EndContractBlock();

            // check that they have ExecutionPermission.  Otherwise OOP remoting fails
            // by shutting down the pipe, leaving the user scratching his head.
            if (!permissionSet.IsUnrestricted())
            {
                SecurityPermission     p             = (SecurityPermission)permissionSet.GetPermission(typeof(SecurityPermission));
                SecurityPermissionFlag requiredFlags = SecurityPermissionFlag.Execution;
                if (p == null || (p.Flags & requiredFlags) != requiredFlags)
                {
                    throw new ArgumentException(Res.NeedSecurityFlags);
                }
            }

            RemotingHelper.InitializeClientChannel();

            AddInServer addInServer = process.GetAddInServer();

            AddInServerWorker addInServerWorker = addInServer.CreateDomain(token, permissionSet);
            AddInEnvironment  fullEnvironment   = new AddInEnvironment(process, addInServerWorker);

            return(ActivateOutOfProcess <T>(token, fullEnvironment, true));
        }