Beispiel #1
0
        private void InitializeIsolatedAddIn()
        {
            var type = this.GetType();

            AppDomainSetup appDomainSetup = AppDomain.CurrentDomain.SetupInformation;
            Evidence       evidence       = AppDomain.CurrentDomain.Evidence;

            appDomainSetup.ApplicationBase = Path.GetDirectoryName(type.Assembly.Location);

            string domainName = this.AddIn.GUID;

            _isolatedDomain = AppDomain.CreateDomain(domainName, evidence, appDomainSetup);
            var proxyAddIn = _isolatedDomain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName);

            _isolatedAddIn = (SolidEdgeFramework.ISolidEdgeAddIn)proxyAddIn;
        }
Beispiel #2
0
        void SolidEdgeFramework.ISolidEdgeAddIn.OnDisconnection(SolidEdgeFramework.SeDisconnectMode DisconnectMode)
        {
            if (IsDefaultAppDomain)
            {
                if (_isolatedAddIn != null)
                {
                    // Forward call to isolated AppDomain.
                    _isolatedAddIn.OnDisconnection(DisconnectMode);

                    // Unload isolated domain.
                    if (_isolatedDomain != null)
                    {
                        AppDomain.Unload(_isolatedDomain);
                    }

                    _isolatedDomain = null;
                    _isolatedAddIn  = null;
                }
            }
            else
            {
                OnDisconnection(DisconnectMode);

                if (_ribbonController != null)
                {
                    try
                    {
                        _ribbonController.Dispose();
                    }
                    catch
                    {
                    }

                    _ribbonController = null;
                }

                if (_edgeBarController != null)
                {
                    try
                    {
                        _edgeBarController.Dispose();
                    }
                    catch
                    {
                    }

                    _edgeBarController = null;
                }

                if (_viewOverlayController != null)
                {
                    try
                    {
                        _viewOverlayController.Dispose();
                    }
                    catch
                    {
                    }

                    _viewOverlayController = null;
                }
            }
        }