Exemple #1
0
        public bool ActivatePlugin()
        {
            try
            {
                osae.AddToLog("Activating Plugin: " + PluginName, true);
                // Create application domain setup information.
                AppDomainSetup domaininfo = new AppDomainSetup();
                domaininfo.ApplicationBase = osae.APIpath;
                //domaininfo.ApplicationTrust = AddInSecurityLevel.Host;

                // Create the application domain.
                AppDomain domain = AppDomain.CreateDomain(PluginName + "_Domain", null, domaininfo);
                // Write application domain information to the console.
                osae.AddToLog("Host domain: " + AppDomain.CurrentDomain.FriendlyName, true);
                osae.AddToLog("child domain: " + domain.FriendlyName, true);
                osae.AddToLog("Application base is: " + domain.SetupInformation.ApplicationBase, true);

                //_addin = _token.Activate<IOpenSourceAutomationAddIn>(domain);
                _process = new AddInProcess(Platform.AnyCpu);
                _addin   = _token.Activate <IOpenSourceAutomationAddInv2>(process, AddInSecurityLevel.FullTrust);
                _enabled = true;
                return(true);
            }
            catch (Exception ex)
            {
                osae.AddToLog("Error activating plugin (" + _pluginName + "): " + ex.Message + " - " + ex.InnerException, true);
                _enabled = false;
                return(false);
            }
            catch
            {
                osae.AddToLog("Error activating plugin", true);
                return(false);
            }
        }
        public bool ActivatePlugin()
        {
            try
            {
                osae.AddToLog("Activating Plugin: " + PluginName, true);
                // Create application domain setup information.
                AppDomainSetup domaininfo = new AppDomainSetup();
                domaininfo.ApplicationBase = osae.APIpath;
                //domaininfo.ApplicationTrust = AddInSecurityLevel.Host;

                // Create the application domain.
                AppDomain domain = AppDomain.CreateDomain(PluginName + "_Domain", null, domaininfo);
                // Write application domain information to the console.
                osae.AddToLog("Host domain: " + AppDomain.CurrentDomain.FriendlyName, true);
                osae.AddToLog("child domain: " + domain.FriendlyName, true);
                osae.AddToLog("Application base is: " + domain.SetupInformation.ApplicationBase, true);

                //_addin = _token.Activate<IOpenSourceAutomationAddIn>(domain);
                _process = new AddInProcess(Platform.AnyCpu);
                _addin = _token.Activate<IOpenSourceAutomationAddInv2>(process,AddInSecurityLevel.FullTrust);
                _enabled = true;
                return true;
            }
            catch(Exception ex)
            {
                osae.AddToLog("Error activating plugin (" + _pluginName + "): " + ex.Message + " - " + ex.InnerException, true);
                _enabled = false;
                return false;
            }
            catch
            {
                osae.AddToLog("Error activating plugin", true);
                return false;
            }
        }