Exemple #1
0
            protected override void Dispose(bool disposing)
            {
                base.Dispose(disposing);

                if (_inner != null)
                {
                    _inner?.Dispose();
                    _inner = null;
                }

                if (_baseIDocHostUIHandler != null && Marshal.IsComObject(_baseIDocHostUIHandler))
                {
                    Marshal.ReleaseComObject(_baseIDocHostUIHandler);
                    _baseIDocHostUIHandler = null;
                }

                if (_unkInnerAggregated != IntPtr.Zero)
                {
                    Marshal.Release(_unkInnerAggregated);
                    _unkInnerAggregated = IntPtr.Zero;
                }

                if (_unkOuter != IntPtr.Zero)
                {
                    Marshal.Release(_unkOuter);
                    _unkOuter = IntPtr.Zero;
                }
            }
Exemple #2
0
            public DCWebBrowserSite(WebBrowser host) : base(host)
            {
                // get the CCW object for this
                _unkOuter = Marshal.GetIUnknownForObject(this);
                Marshal.AddRef(_unkOuter);
                try
                {
                    // aggregate the CCW object with the helper Inner object
                    _inner = new Inner(this);
                    _unkInnerAggregated = Marshal.CreateAggregatedObject(_unkOuter, _inner);

                    // obtain private WebBrowserSite COM interfaces
                    _baseIDocHostUIHandler = (UnsafeNativeMethods.IDocHostUIHandler)Marshal.GetTypedObjectForIUnknown(_unkInnerAggregated, typeof(UnsafeNativeMethods.IDocHostUIHandler));
                }
                finally
                {
                    Marshal.Release(_unkOuter);
                }
            }