Exemplo n.º 1
0
        public override void PrepareChanges()
        {
            this.closed = true;
            bool workDone           = this.configFile.HasBeenModified() && WasModified;
            TransactionOptions opts = new TransactionOptions();

            opts.Timeout        = TimeSpan.FromMinutes(5);
            opts.IsolationLevel = IsolationLevel.Serializable;
            scope = new TransactionScope(TransactionScopeOption.Required, opts, EnterpriseServicesInteropOption.Full);

            if (workDone)
            {
                // if appDir doesnt exist, we must create it before we prepare the config files below
                if (this.mustGenerateAppDir)
                {
                    // create it
                    Directory.CreateDirectory(this.appDir);

                    ToolConsole.WriteLine(SR.GetString(SR.DirectoryCreated, this.appDir));
                }
                // set the COM+ app property
                ComAdminWrapper.SetAppDir(this.appInfo.ID.ToString("B"), this.appDir);
            }

            this.configFile.Prepare();

            if (workDone)
            {
                ToolConsole.WriteLine(SR.GetString((this.configFile.OriginalFileExists ? SR.FileUpdated : SR.FileCreated), configFile.OriginalFileName));
            }


            if (workDone && !this.manifestFile.CurrentExists() && this.hasServices)
            {
                string fileName = this.manifestFile.GetCurrentFileName(false);  // for update
                CreateManifestFile(this.manifestFile.GetCurrentFileName(false));
                ToolConsole.WriteLine(SR.GetString(SR.FileCreated, this.manifestFile.OriginalFileName));
            }

            this.manifestFile.Prepare();

            if (workDone)
            {
                // Now, install the Listener if it isnt already there
                if (this.hasServices && !this.listenerComponentExists)
                {
                    ComAdminWrapper.InstallListener(this.appInfo.ID, this.appDir, this.appInfo.RuntimeVersion);
                }
                else if (!this.hasServices && this.listenerComponentExists)
                {
                    ComAdminWrapper.RemoveListener(this.appInfo.ID);
                }

                if (this.appInfo.IsServerActivated)
                {
                    ToolConsole.WriteWarning(SR.GetString(SR.ShouldRestartApp, this.appInfo.Name));
                }
            }
        }
        public override void Remove(IList <EndpointConfig> endpointConfigs)
        {
            ThrowIfClosed();

            Configuration config = GetConfiguration(false); // not read only

            Debug.Assert(config != null, "config != null");

            bool anyRemoved = false;

            foreach (EndpointConfig endpointConfig in endpointConfigs)
            {
                bool removed = this.BaseRemoveEndpointConfig(config, endpointConfig);
                if (removed)
                {
                    anyRemoved = true;

                    if (NumEndpointsForClsid(config, endpointConfig.Clsid, endpointConfig.Appid) == 0)
                    {
                        // We can only Remove the SVC file when there are no more endpoints for the Clsid
                        this.svcFileManager.Remove(endpointConfig.Appid, endpointConfig.Clsid);
                    }
                    if (!Tool.Options.ShowGuids)
                    {
                        ToolConsole.WriteLine(SR.GetString(SR.InterfaceRemoved, endpointConfig.ComponentProgID, endpointConfig.InterfaceName));
                    }
                    else
                    {
                        ToolConsole.WriteLine(SR.GetString(SR.InterfaceRemoved, endpointConfig.Clsid, endpointConfig.Iid));
                    }
                }
                else if (!endpointConfig.IsMexEndpoint)
                {
                    if (!Tool.Options.ShowGuids)
                    {
                        ToolConsole.WriteWarning(SR.GetString(SR.InterfaceNotExposed, endpointConfig.ComponentProgID, endpointConfig.InterfaceName));
                    }
                    else
                    {
                        ToolConsole.WriteWarning(SR.GetString(SR.InterfaceNotExposed, endpointConfig.Clsid, endpointConfig.Iid));
                    }
                }
            }

            if (anyRemoved)
            {
                WasModified = true;
                config.Save();
            }
        }
        public override void PrepareChanges()
        {
            this.closed = true;
            bool workDone = this.configFile.HasBeenModified() && WasModified;


            this.configFile.Prepare();

            if (workDone)
            {
                ToolConsole.WriteLine(SR.GetString((this.configFile.OriginalFileExists ? SR.FileUpdated : SR.FileCreated), configFile.OriginalFileName));
            }

            this.svcFileManager.Prepare();
        }
Exemplo n.º 4
0
        public override void Remove(IList <EndpointConfig> endpointConfigs)
        {
            ThrowIfClosed();

            Configuration config = GetConfiguration(false); // not read only

            Debug.Assert(config != null, "config != null");

            bool anyRemoved = false;

            foreach (EndpointConfig endpointConfig in endpointConfigs)
            {
                Debug.Assert(endpointConfig.Appid == this.appInfo.ID, "can't remove endpoint for a different application");

                bool removed = this.BaseRemoveEndpointConfig(config, endpointConfig);
                if (removed)
                {
                    anyRemoved = true;
                    if (!Tool.Options.ShowGuids)
                    {
                        ToolConsole.WriteLine(SR.GetString(SR.InterfaceRemoved, endpointConfig.ComponentProgID, endpointConfig.InterfaceName));
                    }
                    else
                    {
                        ToolConsole.WriteLine(SR.GetString(SR.InterfaceRemoved, endpointConfig.Clsid, endpointConfig.Iid));
                    }
                }
                else if (!endpointConfig.IsMexEndpoint)
                {
                    if (!Tool.Options.ShowGuids)
                    {
                        ToolConsole.WriteWarning(SR.GetString(SR.InterfaceNotExposed, endpointConfig.ComponentProgID, endpointConfig.InterfaceName));
                    }
                    else
                    {
                        ToolConsole.WriteWarning(SR.GetString(SR.InterfaceNotExposed, endpointConfig.Clsid, endpointConfig.Iid));
                    }
                }
            }

            this.hasServices = ServiceModelSectionGroup.GetSectionGroup(config).Services.Services.Count > 0;
            if (anyRemoved)
            {
                WasModified = true;
                config.Save();
            }
        }
Exemplo n.º 5
0
        public override void Add(IList <EndpointConfig> endpointConfigs)
        {
            ThrowIfClosed();

            Configuration config = GetConfiguration(false); // not read only

            Debug.Assert(config != null, "config != null");

            bool anyAdded = false;

            foreach (EndpointConfig endpointConfig in endpointConfigs)
            {
                Debug.Assert(endpointConfig.Appid == this.appInfo.ID, "can't add endpoint for a different application");

                bool added = this.BaseAddEndpointConfig(config, endpointConfig);

                if (added)
                {
                    anyAdded = true;

                    // the metadata exchange endpoint is not displayed as a regular endpoint
                    if (endpointConfig.Iid == typeof(IMetadataExchange).GUID)
                    {
                        ToolConsole.WriteLine(SR.GetString(SR.MexEndpointAdded));
                        continue;
                    }

                    if (!Tool.Options.ShowGuids)
                    {
                        ToolConsole.WriteLine(SR.GetString(SR.InterfaceAdded,
                                                           endpointConfig.ComponentProgID,
                                                           endpointConfig.InterfaceName));
                    }
                    else
                    {
                        ToolConsole.WriteLine(SR.GetString(SR.InterfaceAdded,
                                                           endpointConfig.Clsid,
                                                           endpointConfig.Iid));
                    }
                }
                else
                {
                    // the metadata exchange endpoint is not displayed as a regular endpoint
                    if (endpointConfig.Iid == typeof(IMetadataExchange).GUID)
                    {
                        if (!Tool.Options.ShowGuids)
                        {
                            ToolConsole.WriteWarning(SR.GetString(SR.MexEndpointAlreadyExposed, endpointConfig.ComponentProgID));
                        }
                        else
                        {
                            ToolConsole.WriteWarning(SR.GetString(SR.MexEndpointAlreadyExposed, endpointConfig.Clsid));
                        }
                    }
                    else
                    {
                        if (!Tool.Options.ShowGuids)
                        {
                            ToolConsole.WriteWarning(SR.GetString(SR.InterfaceAlreadyExposed,
                                                                  endpointConfig.ComponentProgID,
                                                                  endpointConfig.InterfaceName));
                        }
                        else
                        {
                            ToolConsole.WriteWarning(SR.GetString(SR.InterfaceAlreadyExposed,
                                                                  endpointConfig.Clsid,
                                                                  endpointConfig.Iid));
                        }
                    }
                }
            }

            if (anyAdded)
            {
                WasModified = true;

                config.Save();
            }

            this.hasServices = true;
        }
        public override void Add(IList <EndpointConfig> endpointConfigs)
        {
            ThrowIfClosed();

            Configuration config = GetConfiguration(false); // not read only

            Debug.Assert(config != null, "config != null");

            bool         anyAdded         = false;
            const string systemWebSection = "system.web";

            foreach (EndpointConfig endpointConfig in endpointConfigs)
            {
                Guid appid;
                //verify that we someone did not delete and reinstall the app from underneath us
                if (this.svcFileManager.ResolveClsid(endpointConfig.Clsid, out appid))
                {
                    if (endpointConfig.Appid != appid)
                    {
                        ToolConsole.WriteError(SR.GetString(SR.AppIDsDontMatch), "");
                        return;
                    }
                }
            }

            SystemWebSectionGroup swsg = (SystemWebSectionGroup)config.GetSectionGroup(systemWebSection);
            CompilationSection    compilationSection = swsg.Compilation;

            if (string.IsNullOrEmpty(compilationSection.TargetFramework) && RuntimeVersions.V40 == this.runtimeVersion)
            {
                anyAdded = true;
                compilationSection.TargetFramework = ".NETFramework, Version=v4.0";
            }

            foreach (EndpointConfig endpointConfig in endpointConfigs)
            {
                bool added = this.BaseAddEndpointConfig(config, endpointConfig);
                if (added)
                {
                    this.svcFileManager.Add(endpointConfig.Appid, endpointConfig.Clsid);
                    anyAdded = true;

                    // the metadata exchange endpoint is not displayed as a regular endpoint
                    if (endpointConfig.Iid == typeof(IMetadataExchange).GUID)
                    {
                        ToolConsole.WriteLine(SR.GetString(SR.MexEndpointAdded));
                        continue;
                    }

                    if (!Tool.Options.ShowGuids)
                    {
                        ToolConsole.WriteLine(SR.GetString(SR.InterfaceAdded, endpointConfig.ComponentProgID, endpointConfig.InterfaceName));
                    }
                    else
                    {
                        ToolConsole.WriteLine(SR.GetString(SR.InterfaceAdded, endpointConfig.Clsid, endpointConfig.Iid));
                    }
                }
                else
                {
                    // the metadata exchange endpoint is not displayed as a regular endpoint
                    if (endpointConfig.Iid == typeof(IMetadataExchange).GUID)
                    {
                        if (!Tool.Options.ShowGuids)
                        {
                            ToolConsole.WriteWarning(SR.GetString(SR.MexEndpointAlreadyExposed, endpointConfig.ComponentProgID));
                        }
                        else
                        {
                            ToolConsole.WriteWarning(SR.GetString(SR.MexEndpointAlreadyExposed, endpointConfig.Clsid));
                        }
                    }
                    else
                    {
                        if (!Tool.Options.ShowGuids)
                        {
                            ToolConsole.WriteWarning(SR.GetString(SR.InterfaceAlreadyExposed, endpointConfig.ComponentProgID, endpointConfig.InterfaceName));
                        }
                        else
                        {
                            ToolConsole.WriteWarning(SR.GetString(SR.InterfaceAlreadyExposed, endpointConfig.Clsid, endpointConfig.Iid));
                        }
                    }
                }
            }

            if (anyAdded)
            {
                WasModified = true;
                config.Save();
            }
        }