public override void Install(IDictionary stateSaver)
        {
            //This effectively does what gacutil does.
            new System.EnterpriseServices.Internal.Publish().GacInstall("EvilNetConnectionWMIProvider.dll");

            base.Install(stateSaver);
            System.Runtime.InteropServices.RegistrationServices RS = new System.Runtime.InteropServices.RegistrationServices();
        }
        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);
            System.Runtime.InteropServices.RegistrationServices RS = new System.Runtime.InteropServices.RegistrationServices();

            //This should be fixed with .NET 3.5 SP1
            //RS.RegisterAssembly(System.Reflection.Assembly.LoadFile(Environment.ExpandEnvironmentVariables(@"%PROGRAMFILES%\Reference Assemblies\Microsoft\Framework\v3.5\System.Management.Instrumentation.dll")), System.Runtime.InteropServices.AssemblyRegistrationFlags.SetCodeBase);
        }
        public override void Install(IDictionary stateSaver)
        {
            //This effectively does what gacutil does.
            new System.EnterpriseServices.Internal.Publish().GacInstall("EvilNetConnectionWMIProvider.dll");

            base.Install(stateSaver);
            System.Runtime.InteropServices.RegistrationServices RS = new System.Runtime.InteropServices.RegistrationServices();
        }
 public override void Install(IDictionary stateSaver)
 {
     base.Install(stateSaver);
     System.Runtime.InteropServices.RegistrationServices RS = new System.Runtime.InteropServices.RegistrationServices();
     try
     {
         new System.EnterpriseServices.Internal.Publish().GacInstall(System.Reflection.Assembly.GetExecutingAssembly().Location);
     }
     catch { }
 }
        /// <summary>
        ///		Called during Outlook startup.
        /// </summary>
        /// <remarks>
        ///		Should not be called from code.
        /// </remarks>
        /// <param name="application">The Outlook application.</param>
        /// <param name="connectMode">The startup type.</param>
        /// <param name="addInInst">This addin.</param>
        /// <param name="custom">Any custom arguments passed to Outlook.</param>
        public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
        {
            addInInstance = addInInst;
            System.Runtime.InteropServices.RegistrationServices reg = new System.Runtime.InteropServices.RegistrationServices();
            string progid = reg.GetProgIdForType(this.GetType());

            manager = new OutlookUIManager((RlOutlook.Application)application, this, progid);
            manager.OutlookClosed += new OutlookEventHandler(OnOutlookClosed);

            if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup)
            {
                OnStartupComplete(ref custom);
            }
        }
示例#6
0
        private static int moveAndRegisterFile(string fileToSaveAndReg)
        {
            int returnInt = -1; //file registration return code

            string curFileDirectory = Path.GetDirectoryName(fileToSaveAndReg);
            string systemDirectory  = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86);

            string newFileLocation = fileToSaveAndReg.Replace(curFileDirectory, systemDirectory);

            if (File.Exists(newFileLocation) == false)
            {
                File.Copy(fileToSaveAndReg, newFileLocation, false);
            }

            try {
                File.Delete(fileToSaveAndReg);
            }
            catch {
                //don't really care right now
            }

            using (System.Diagnostics.Process regsvr32Process = new System.Diagnostics.Process()) {
                regsvr32Process.StartInfo.FileName               = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.SystemX86), "regsvr32.exe");
                regsvr32Process.StartInfo.CreateNoWindow         = true;
                regsvr32Process.StartInfo.RedirectStandardOutput = true;
                regsvr32Process.StartInfo.UseShellExecute        = false;

                regsvr32Process.StartInfo.Arguments = string.Format("/s \"{0}\"", newFileLocation);
                regsvr32Process.Start();
                regsvr32Process.WaitForExit();
                returnInt = regsvr32Process.ExitCode;
            }

            //need to handle the possibility that the file is a .Net assembly, and not a COM library. If COM registration was successful, the return code will have been 0:
            if (returnInt != 0)
            {
                System.Reflection.Assembly curAssembly = null;

                try {
                    curAssembly = System.Reflection.Assembly.LoadFrom(newFileLocation);
                }
                catch {
                    return(returnInt);
                }

                System.Runtime.InteropServices.RegistrationServices regAsm = new System.Runtime.InteropServices.RegistrationServices();

                try { regAsm.RegisterAssembly(curAssembly, System.Runtime.InteropServices.AssemblyRegistrationFlags.SetCodeBase); }
                catch {
                    try {
                        regAsm.RegisterAssembly(curAssembly, System.Runtime.InteropServices.AssemblyRegistrationFlags.None);
                    }
                    catch {
                        return(returnInt);
                    }
                }
            }


            return(returnInt);
        }