Beispiel #1
0
        /// <summary>
        /// Override Install method to allow custom actions during OWMail 2.0 setup.
        /// </summary>
        /// <param name="stateSaver">An IDictionary that contains the context information associated with the installation.</param>
        public override void Install(IDictionary stateSaver)
        {
            try
            {
                string AppID   = null;
                string TypeLib = null;

                // Get the location of the current assembly
                string Assembly = GetType().Assembly.Location;

                // Install the application
                RegistrationHelper rh = new RegistrationHelper();
                rh.InstallAssembly(Assembly, ref AppID, ref TypeLib, InstallationFlags.FindOrCreateTargetApplication);

                //RegistrationConfig configuration = new RegistrationConfig();

                // Save the state - you will need this for the uninstall
                stateSaver.Add("AppID", AppID);
                stateSaver.Add("Assembly", Assembly);
            }
            catch (Exception ex)
            {
                StreamWriter sw = File.AppendText(@"c:\OWMailInstallerErrors.log");
                sw.WriteLine("Uninstall Error: {0}", ex.Message);
                sw.Close();
            }
        }
Beispiel #2
0
        protected override void DoExecute(ITaskContext context)
        {
            RegistrationHelper regHelper = new RegistrationHelper();

            string application = null;
            string tlbFileName = null;

            regHelper.InstallAssembly(
                assemblyFileName,
                ref application,
                ref tlbFileName,
                InstallationFlags.FindOrCreateTargetApplication | InstallationFlags.ReportWarningsToConsole);
        }
        //=========================================================================================
        //
        //=========================================================================================
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);

            try
            {
                string assembly = this.GetType().Assembly.Location;

                string applicationId = null;
                string typeLib       = null;

                RegistrationHelper registrationHelper = new RegistrationHelper();
                registrationHelper.InstallAssembly(assembly, ref applicationId, ref typeLib, InstallationFlags.FindOrCreateTargetApplication);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            // Register a private assembly.
            RegistrationHelper rh = new RegistrationHelper();

            try
            {
                string comPlusAppName = "NewComPlusApp";
                string typeLibName    = "FooServicedComp.tlb";
                rh.InstallAssembly("FooServicedComp.dll",
                                   ref comPlusAppName,
                                   ref typeLibName,
                                   InstallationFlagsFindOrCreateTargetApplication);
            }
            catch (RegistrationException rhex)
            {
                Console.WriteLine(rhex.Message);
            }
        }
        /// <include file='doc\ImportUtil.uex' path='docs/doc[@for="ComManagedImportUtil.InstallAssembly"]/*' />
        public void InstallAssembly(string asmpath, string parname, string appname)
        {
            try
            {
                DBG.Info(DBG.Registration, "Attempting install of " + asmpath + " to app " + appname + " in partition " + parname);
                String            tlb   = null;
                InstallationFlags flags = InstallationFlags.Default;

                RegistrationHelper h = new RegistrationHelper();
                h.InstallAssembly(asmpath, ref appname, parname, ref tlb, flags);
            }
            catch (Exception e)
            {
                EventLog.WriteEntry(Resource.FormatString("Reg_InstallTitle"),
                                    Resource.FormatString("Reg_FailInstall", asmpath, appname) + "\n\n" + e.ToString(),
                                    EventLogEntryType.Error);

                throw;
            }
        }
Beispiel #6
0
        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            //(Workspace.Get(context)).TryGetLocalItemForServerItem(
            RegistrationHelper registrationHelper = new RegistrationHelper();
            string             appName            = ApplicationName.Get(context);
            string             tlb = TLB.Get(context);

            string comAssemblyPath = COMAssembly.Get(context);

            if (InstallAssembly.Get(context))
            {
                registrationHelper.InstallAssembly(comAssemblyPath, ref appName, ref tlb, InstallationFlags.Default);
                ApplicationName.Set(context, appName);
                TLB.Set(context, tlb);
            }
            else
            {
                registrationHelper.UninstallAssembly(comAssemblyPath, appName);
            }
        }
Beispiel #7
0
        /// <summary>
        /// When overridden in a derived class, performs the installation.
        /// </summary>
        /// <param name="stateSaver">An <see cref="T:System.Collections.IDictionary"/> used to save information needed to perform a commit, rollback, or uninstall operation.</param>
        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);
            string appID   = string.Empty;
            string typeLib = string.Empty;
            // Get the location of the current assembly
            string assemblyLocation = GetType().Assembly.Location;

            // Install the application
            try
            {
                RegistrationHelper regHelper = new RegistrationHelper();
                regHelper.InstallAssembly(assemblyLocation, ref appID, ref typeLib, InstallationFlags.FindOrCreateTargetApplication);
                // Save the state - you will need this for the uninstall
                stateSaver.Add("AppID", appID);
                stateSaver.Add("Assembly", assemblyLocation);
            }
            catch (Exception ex)
            {
                throw new InstallException("Error during registration of " + GetType().Assembly.FullName, ex);
            }
        }
        static void Main(string[] args)
        {
            //<snippet0>
            try
            {
                //<snippet1>
                string             applicationName = "Queued Component";
                string             typeLibraryName = null;
                RegistrationHelper helper          = new RegistrationHelper();
                // Call the InstallAssembly method passing it the name of the assembly to
                // install as a COM+ application, the COM+ application name, and
                // the name of the type library file.
                // Setting the application name and the type library to NULL (nothing in Visual Basic .NET
                // allows you to use the COM+ application name that is given in the assembly and
                // the default type library name. The application name in the assembly metadata
                // takes precedence over the application name you provide to InstallAssembly.
                helper.InstallAssembly(@"C:..\..\QueuedComponent.dll", ref applicationName, ref typeLibraryName, InstallationFlags.CreateTargetApplication);
                Console.WriteLine("Registration succeeded: Type library {0} created.", typeLibraryName);
                Console.Read();
                //</snippet1>

                //<snippet2>
                // Create a RegistrationConfig object and set its attributes
                // Create a RegistrationHelper object, and call the InstallAssemblyFromConfig
                // method by passing the RegistrationConfiguration object to it as a
                // reference object
                RegistrationConfig registrationConfiguration = new RegistrationConfig();
                registrationConfiguration.AssemblyFile      = @"C:..\..\QueuedComponent.dll";
                registrationConfiguration.Application       = "MyApp";
                registrationConfiguration.InstallationFlags = InstallationFlags.CreateTargetApplication;
                RegistrationHelper helperFromConfig = new RegistrationHelper();
                helperFromConfig.InstallAssemblyFromConfig(ref registrationConfiguration);
                //</snippet2>
            }
            // <snippet3>

            catch (RegistrationException e)
            {
                Console.WriteLine(e.Message);
                // </snippet3>

                // <snippet4>
                // Check whether the ErrorInfo property of the RegistrationException object is null.
                // If there is no extended error information about
                // methods related to multiple COM+ objects ErrorInfo will be null.
                if (e.ErrorInfo != null)
                {
                    // Gets an array of RegistrationErrorInfo objects describing registration errors
                    RegistrationErrorInfo[] registrationErrorInfos = e.ErrorInfo;

                    // Iterate through the array of RegistrationErrorInfo objects and disply the
                    // ErrorString for each object.

                    foreach (RegistrationErrorInfo registrationErrorInfo in registrationErrorInfos)
                    {
                        Console.WriteLine(registrationErrorInfo.ErrorString);
                    }
                }
                // </snippet4>
                Console.Read();
            }
            //</snippet0>
        }
Beispiel #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stateSaver"></param>
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            try
            {
#if DEBUG
                Debug.WriteLine("Begin component installation process...");
                EventLog.WriteEntry(ToString(), "Begin component installation process...", EventLogEntryType.Information);
#endif
                string appID   = null;
                string typeLib = null;
                // Get the location of the current assembly
                var assembly = GetType().Assembly.Location;
                // Install the application
                var regHelper = new RegistrationHelper();
                regHelper.InstallAssembly(assembly, ref appID, ref typeLib, InstallationFlags.FindOrCreateTargetApplication);
                // Save the state - you will need this for the uninstall
                stateSaver.Add("AppID", appID);
                stateSaver.Add("Assembly", assembly);
#if DEBUG
                Debug.WriteLine("Installation successfull");
                EventLog.WriteEntry(ToString(), "Installation successfull", EventLogEntryType.Information);
#endif

                #region Setup Options form call

                var frmOptions = new SetupOptions();
                if (frmOptions.ShowDialog() == DialogResult.OK)
                {
#if DEBUG
                    Debug.WriteLine("Configure component options...");
                    EventLog.WriteEntry(ToString(), "Configure component options...", EventLogEntryType.Information);
#endif

                    // HKLM\Software\TopBook\ECR\ECRManagedComObjects\ECRDataReader
                    var _key = Registry.LocalMachine.OpenSubKey(REG_BASE_KEY + REG_ECR_DATAREADER_KEY, true);
                    if (_key == null)
                    {
                        Registry.LocalMachine.CreateSubKey(REG_BASE_KEY + REG_ECR_DATAREADER_KEY, RegistryKeyPermissionCheck.ReadWriteSubTree);
                        Registry.LocalMachine.Flush();
                        _key = Registry.LocalMachine.OpenSubKey(REG_BASE_KEY + REG_ECR_DATAREADER_KEY, true);
                    }
                    if (_key != null)
                    {
                        _key.SetValue(REG_PARAMETER_SERVER_ECR_CONFIG, frmOptions.ServerLocation);
                        Registry.LocalMachine.Flush();
                        _key.SetValue(REG_PARAMETER_CONNECTION_TIMEOUT_ECR_CONFIG, frmOptions.ConnectionTimeout.ToString());
                        Registry.LocalMachine.Flush();
                        _key.SetValue(REG_PARAMETER_COMMAND_TIMEOUT_ECR_CONFIG, frmOptions.CommandTimeout.ToString());
                        Registry.LocalMachine.Flush();
                        _key.SetValue(REG_PARAMETER_DEBUG_FLAG, frmOptions.DebugMode.ToString());
                        Registry.LocalMachine.Flush();
                    }
#if DEBUG
                    Debug.WriteLine("Component options configured successfully");
                    EventLog.WriteEntry(ToString(), "Component options configured successfully", EventLogEntryType.Information);
#endif
                }

                #endregion

                #region Identity Options form call

                var frmIdentityOptions = new IdentityOptions();
                if (frmIdentityOptions.ShowDialog() == DialogResult.OK)
                {
                    if (frmIdentityOptions.UserName.Length > 0)
                    {
#if DEBUG
                        Debug.WriteLine("Configure component identity...");
                        EventLog.WriteEntry(ToString(), "Configure component identity...", EventLogEntryType.Information);
#endif

                        var _catalog = new COMAdmin.COMAdminCatalog();
                        var _coll    = (COMAdmin.COMAdminCatalogCollection)_catalog.GetCollection("Applications");
                        _coll.Populate();

                        foreach (COMAdmin.COMAdminCatalogObject _app in _coll)
                        {
                            if (_app.Name.ToString() != Assembly.GetExecutingAssembly().GetName().Name)
                            {
                                continue;
                            }
                            _app.set_Value("Identity", frmIdentityOptions.UserName);
                            _app.set_Value("Password", frmIdentityOptions.Password);
                            _coll.SaveChanges();
#if DEBUG
                            Debug.WriteLine("Identity configured successfully");
                            EventLog.WriteEntry(ToString(), "Identity configured successfully", EventLogEntryType.Information);
#endif
                            break;
                        }
                    }
                }

                #endregion

                #region Export Proxy form call

                var frmExportProxy = new ExportProxy();
                if (frmExportProxy.ShowDialog() == DialogResult.OK)
                {
                    if (frmExportProxy.ProxyFileName.Length > 0)
                    {
#if DEBUG
                        Debug.WriteLine("Export Proxy .MSI file...");
                        EventLog.WriteEntry(ToString(), "Export Proxy .MSI file...", EventLogEntryType.Information);
#endif

                        var _catalog = new COMAdmin.COMAdminCatalog();
                        _catalog.ExportApplication(Assembly.GetExecutingAssembly().GetName().Name, frmExportProxy.ProxyFileName, 2);


#if DEBUG
                        Debug.WriteLine("Proxy .MSI file exported successfully");
                        EventLog.WriteEntry(ToString(), "Proxy .MSI file exported successfully", EventLogEntryType.Information);
#endif
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
#if DEBUG
                Debug.WriteLine(string.Format("Installion error: {0}", ex));
#endif
                EventLog.WriteEntry(ToString(), string.Format("Installation error: '{0}'", ex.Message), EventLogEntryType.Error);
                // If the installer catches the exception it will display
                // an error message.  Show a friendly error message
                throw new ApplicationException("Installion error", ex);
            }
        }